- Home /
Changing transform.parent moved the position of the parent to the position of the child gameobject.
I created an empty gameobject through script . Then i set the position of the empty gameobject. Then in the script i set the empty gameobject as a parent of an existing object. Somehow the empty gameobject position moved to the position of the child gameobject.
Before changing parent :
After changing parent :
It can be seen that after changing the transform.parent of the Main Camera to New Game Object , the position of the New Game Object moved to the position of the Main Camera. I printed the transform.position of the New Game Object (the world position) , it remains the same , but the actual position of the New Game Object clearly has changed.
Why is this happening ? And what is the workaround to fix this problem ?
Your answer
Follow this Question
Related Questions
Resetting Ball Object to the original parent and position 2 Answers
Place child GameObject at absolute world position 3 Answers
transform.position is wrong when parent has scale different than Vector3.one 0 Answers
Parented bone has a weird position in unity,Parented bone has weird local position in unity 0 Answers
How do I get one object to move to (the closet) another object? 2 Answers