transform.position incorrect.

Here’s my issue. I have a player gameobject and its transform.position is (0,0,0). However it appears at (2,2 , 1,8 , 0) which is a real bother. I’m fairly new to Unity and thus I’d be really grateful if someone would help me out with this. The problem doesn’t appear to be the script, although I may be wrong. Does anyone know what may have cause this ?
Oh and for some reason I can’t post in answers, so I thought I’d post it here. Sorry if it’s not the right place to post this.

1 Like

What do you mean by ‘appears’? As in the object visually seems to be in that location? A rigidbody with colliders has a simulated reaction at that location? The GameObject’s transform’s world position reports that position? Something else?

My first instinct is that your player object is the child of another GameObject and that parent object has the the position you are seeing. Remember that the inspector of the transform component displays local coordinates that are always in relation to the parent object whereas an object’s transform.position value will always report the global position.

2 Likes

Well… Uh… You’re right. I was so fixated on my other game objects that I forgot that in order to have an organized project I created game objects to act as folders. The one for my player game object turned out to be somewhere in the top right corner of the scene. Once I reset it, everything worked fine. It turned out to be a lot more simple that I initially thought. I guess it’s true the dumbest mistakes are the hardest ones to see. Thanks a lot man.

Welcome to the hierarchy! children follow parents but can have their own relative positioning. These rules can break if the children have rigidbodies, and in this case, the physics engine will usually take over. Usually.

1 Like