Home > database >  Why does Unity say Transform has no definition for position?
Why does Unity say Transform has no definition for position?

Time:10-20

In every other project I've used transform.position it works fine, but now it says there's no definition for position. I even tried making a new project and re-writing the code. The file name is exactly the same as the class name, and everything is spelled correctly, here's the line that it says has the error.

playerObject.transform.postion = pos;

CodePudding user response:

Your title spells it position, but your code spells it postion. It is a typo as Transform does not contain a definition of postion, but does for position.

CodePudding user response:

The Problem as I can see it is that when pos is equal to null, it will give transform.position the value of null. Which will give the error that it has no definition.

To fix make sure pos is not equal to null

  • Related