Hi,
I have a group of objects that changes based on user input and I need them to center when I run a function to do so. They are all children of their parent and they need to have their center be the parent’s position. i.e. the center of their local positions needs to be 0, 0. How do I achieve this?
Thanks,
Ethan
Problem solved! I had this working and I didn’t even realize it.
For those who want to do a similar thing, I have this in a function…
Bounds bounds = new Bounds();
for (int i = 0; i < buildParentObject.transform.childCount; i++)
bounds.Encapsulate(buildParentObject.transform.GetChild(i).transform.localPosition);
for (int i = 0; i < buildParentObject.transform.childCount; i++)
buildParentObject.transform.GetChild(i).Translate(-bounds.center);
It seems very inefficient but hey, it works!