- Home /
How to change parent pivot to center no matter childs transform ?
I create a gameobject , and add it with some childs,the childs's transform all are (0,0,0),the parent transform 's pivot is center; but when i chang some child transform not (0,0,0) ,the parent transform pivot will change except center ,i 'd like to set parent pivot always center , any one have any ideas?
Please post what you currently have for the various object RectTransforms.
For the parent object, I'd think all anchor points ($$anonymous$$ & max), AND the pivot point, should all be 0.5f.
I don't use recttransform with 2D ; i just only use a general game object with some child sprites and labels by NGUI.
Oh, I'm confused then, what pivot point are you talking about? I though those were only in RectTransforms. Either way though, changing a child's transform, should not affect it's parents transform. Can you show how you are changing the child object's position? Or do you just change the transform in the child's inspector window?
Ah, I see from parent2.png, that you want to move around the parent object, such that: it is always in the "center" of all your child objects. Is that correct? (if so, suggest you edit OP to include that particular)
How exactly would you like to define "center"?
The average position of all child objects?(easier)
Or a point that is a $$anonymous$$imal distance from all child objects?(harder)
The center between the maximum and $$anonymous$$imum child x,y values. (easier)