|
I am dynamically generating 6 columns and rows of cubes in a loop as children of a gameObject and then setting their transform to parent so I can rotate , move or scale the parent and the children will all move as well. This starts the cube 1 at 0,0 and increments position by cube.x + cube.width. When rotating, this will mean the cubes are moved along the left edge (0,0). I want to make the generated cubes sit at parent.width / 2 and parent.height / 2. Below is an image to demonstrate what I wish to do:-
Does Unity contain helper methods to adjust the center point of the parent so that the cubes can be moved / scaled on a central point? E.g. centerPoint.x = this.width / 2 Thanks
(comments are locked)
|
|
I'm not sure what you mean exactly, but whatever it is you're wanting to do, you should be able to accomplish it by manipulating the Transform.position and Transform.localPosition fields for the parent and child objects (either in the inspector or via scripting) as needed. Thanks for the reply Jesse. I have updated the post with an image to make what I am trying to do a bit clearer.
Dec 04 '10 at 09:12 PM
boymeetsrobot
I don't know of any shortcuts off the top of my head (aside from manipulating the positions as described previously). Maybe someone else will be able to offer an answer though.
Dec 04 '10 at 10:47 PM
Jesse Anders
(comments are locked)
|
|
Have a look at the following script : Positions are relative to the parent GO, so apply this script to the parent GO.
Dec 31 '10 at 01:08 AM
uhahaha
(comments are locked)
|


dupe? http://answers.unity3d.com/questions/262406/how-to-change-the-pivot-to-an-object-in-an-animati.html