transform.position is reporting the wrong values?

Please see the screenshot below for details.

I have a GameObject located at position (0,0,0). When I examine the transform.position of the object however, it tells me it is at (-2.5,0,-5). Weird, right?

I keep thinking that maybe I’m looking at the wrong GameObject or the wrong values but I verified it by putting in a breakpoint and examining the object properties.

If you look at the third line below, you’ll see it says transform={Transform}pos:(0,0,0) which is correct.

But if you then look down at the actual “position” property, it shows the (-2.5, 0, -5).

Then again, it seems this transform also has a transform, and that one seem to be at the correct position…

What is going on here? Why are the values not matching up? It’s screwing up my game logic…

Thanks in advance

Well I cant be for sure but it sounds like your refrencing the wrong transform/pos. There is a Local and a World/Global position. When you are looking at POS/Transform Positions threw like transform.position this will give you the Global Position, so you can be using the wrong position variables. When looking in the editor, see the buttons for Local/World and make sure they are set to how you are reading it.
The Position data is usually based on the ‘Parent’ object if its a child, so its position data is based on what its Parent object is ie what its attached to not its own position. For example a Camera attached to the player will generally not change the Position data if the camera is fixed even though the player is moving around the camera isnt moving its just following.

Btw you should never set the world coordinates directly, use transform.localPosition if you want to directly affect the position.

It seems that “localPosition” is the property I need to be looking for…