- Home /
Question by
tcatal1999 · Aug 05, 2020 at 10:43 PM ·
parentingparent-childparent transformparent and child
Why Deparenting The First Child Changes Position of The Parent
I have three balls attached to a parent. When they hit an obstacle, I destroy the balls. However, when the first child of the parent is destroyed, the parent's position changes - its y value changes. Then another ball becomes the first child and the same thing happens. When the destroyed ball is not the first child, then the parent's location does not change at all. This seemed weird to me. How can I solve this? Can I disable recalculation of parent's new position after deparenting?
I use the below lines. After 1 second, I destroy the ball. gameObject.transform.SetParent(null);
transform.localScale = new Vector3(0, 0, 0);
Comment