Transform.position won't give the true position of the object

Hello! I hope y’all having a good day!
I’ve encountered an issue here; transform.position won’t give me the true position of the object. I executed that line ( along with a debug.log )of code which is attached to one of my obstacles in the scene. The position the code gives me differs from the one in the inspector.
That’s not the first time I’ve crossed a position problem. I think each obstacle in my scene has that issue, whenever I try to copy an object’s position and paste them into another object, I get the wrong displacements.

1 Like

Hi BlueGoblin,

What is the “true position”?

The Inspector shows the local position of the game object relative to its parent. In the code, that would be transform.localPosition. transform.position is the global position relative to the origin of the game world, which is (0, 0, 0).

Maybe there is a misunderstanding?


See also:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms