Hi, I’m a bit confused as to why my GameObject seems to show different X positions in the inspector vs if I use print(foo.transform.position.x). If I move my object to the right, the console shows position.x increasing positively. However, if I select the object in the inspector, the X position moves negatively. Whats going on?
There are two buttons just below the menu. One says either “Pivot” or “Center” and the other says “Local” or “Global”. Chances are that the latter button is on local, which means that you see the coordinates in local coordinates, while transform.position gives world coordinates (i.e. global). Now if the parent of your GameObject is not centered at global (0,0,0) then the local and the global/world coordinates will differ.
Btw you should never set the world coordinates directly, use transform.localPosition if you want to directly affect the position.