unity3d - Rotation issue in Unity 3D -
i have 2 square empty gameobjects. both have cube object appended child. top empty gameobject appended child 2 lower one. how can rotate top empty gameobject, inner cube object still on other cube object (right picture)?
when use transform.localrotation
, transform.localeulerangles
or transform.rotate
, top object rotate on left picture.
this kind of rotation implies change of object's position well. see 2 ways solve this:
- use transform.rotatearound , specify intersection of both, here blue z axis offset. maybe easier use empty object coordinates.
- a hinge joint. lets coinfigure behaviour works non-kinmatic objects only. have apply forces top object under control of physics engine. depends on remaining part of game if want.
- [update]
if position emptygameobject
@ right place i.e. intersection, , move cube child object half of side length, can desired rotation when rotating cube instead of parent. if need parent independent object, might introduce empty, like:
- /rotatingachorempty (placed @ intersection)
- /rotatingachorempty/topempty (position = distance between center , intersection line)
- /rotatingachorempty/topempty/topcube (cube itself)
Comments
Post a Comment