Reputation: 111
I have two square empty GameObjects. Both have a cube Object appended as a child. The top empty GameObject is also appended as a child two the lower one. How can I rotate the top empty GameObject, so the inner cube object is still on the other cube object (Right picture)?
When I use something like transform.localRotation
, transform.localEulerAngles
or transform.Rotate
, the top object will always rotate like on the left picture.
Upvotes: 1
Views: 1997
Reputation:
Model your cubes in a 3d program like 3ds max or blender and change the pivot to the bottom of the cube where you want to rotate, its easier than to script to change position while rotating.
Upvotes: 0
Reputation: 13146
This kind of rotation implies a change of the object's position as well. I see two ways to solve this:
GameObject
at the right place i.e. the intersection, and move the cube child object by half of its side length, you can get the desired rotation when rotating the cube instead of the parent. If you need a parent as independent object, you might introduce another empty, something like:Upvotes: 1