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.

rotation of top empty gameobject

this kind of rotation implies change of object's position well. see 2 ways solve this:

  1. use transform.rotatearound , specify intersection of both, here blue z axis offset. maybe easier use empty object coordinates.
  2. 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.
  3. [update]
    if position empty gameobject @ 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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -