- Home /
unity parent child scale bug
I have two GameObject in my project
a. GameObject1 size is x = 5 y = 5 z = 5
b. GameObject2 size is x = 1 y = 1 z = 1
and
GameObject2.transform.parent = GameObject1.tranform;
GameObject2.transform.localScale = new vector3(1,1,1);
and
change size GameObject1!! I can't understand this situation.
I can see GameObject1 size x = 5 y = 5 z= 5 in inspector
but GameObject1 size looks like x = 5 y = 20 z = 5. is this bug?
Answer by Zoelovezle · Jan 05, 2016 at 11:54 AM
Its not bug, the child size is with reference to the parent size.
Suppose , the X-Axis of Parent and child is 0 Now if you changed Parent X- Axis to 5 , the X-Axis of Parent will be 5 globally , and X-Axis of Child will globally changed to 5 but you will see its local position .
//In reality the X position of child will be
X position of child is = (localPosition.x of Child + localPosition.x of parent)
But in the Inspector panel you will just the
X position of child is =( localPosition.x of Child )
Hope you understand this. Child transform is basically reference to the parent.