The question is answered, right answer was accepted
How to disable child adopting the transform of its new parent object?
Hey, I've just stumbled upon something weird where when I make an object at position (-5336.3, 11.5, 5952) the child of an empty at position (0, 0, 0) the child object changes its transform to (0, 0, 0). Anyone know what could be making this occur and how to stop it?
Your question is not very clear.
Supposing you have an object called Parent
and an object called Child
which is a child of Parent
. The position of Child
in the inspector is its relative position to its parent. It's not it's world position. So if you move Parent
to (-5336.3, 11.5, 5952), Child
will keep its relative position to Parent
(0,0,0) and move a long it to (-5336.3, 11.5, 5952).
That's the normal behaviour
Answer by Doctor_ED · May 18, 2019 at 11:22 AM
I assume that you use Transform.SetParent(), and it takes two parameters. The second one, of type bool determines whether or not the object will keep it's world relative transform (position, rotation, scale). Try changing that parameter.
Thanks for the reply, just figured it out, dumb mistake was that I see$$anonymous$$gly turned the scale of the parent down to (0, 0, 0) as well as position.
Follow this Question
Related Questions
How can the pivot point of a object be changed during Runtime? 0 Answers
Transform.childCount and Transform.GetChild behavior 1 Answer
Foreach loop not going through all elements 1 Answer
how to add prefab to gameobject? 2 Answers
reset a GameObject parents childs to 0 if a item has changed its parent 2 Answers