- Home /
Setting children position to Vector3.zero doesn't make them go to center of parent?
I thought I remember a child's position being relative to it's parent, so setting the child's position to Vector3.zero would make it go to the center of it's parent, but this does not seem to be the case and it is messing up my code, any ways to fix this?
EDIT: My game is 2D, could that have anything to do with it?
No, and this is just one of the strange position issues I'm having. Whenever I instantiate something, it ignores the position parameter that I give it and instantiates it at the prefabs position ins$$anonymous$$d.
Answer by bobisgod234 · Apr 24, 2018 at 02:10 AM
transform.position is based in world coordinates. When you set transform.position to Vector3.zero, you are putting the object in the center of the gameworld.
Assign Vector3.zero to transform.localPosition to set it to the center of its parent.
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Instantiate as child Issue regarding 2D platformer melee system 0 Answers
Moving parent to position of child 0 Answers
How to hold a child objects position relative to parent as it moves. 1 Answer
How make an object child of other object without changing the child position? 0 Answers