Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to have frame of reference of an object to be at it's tip than at its center?

Discussion in 'Physics' started by ambareeshsrja16, Jul 6, 2019.

  1. ambareeshsrja16

    ambareeshsrja16

    Joined:
    Jun 26, 2019
    Posts:
    12
    I have got an imported .obj object (mesh) which I am trying to render in Unity. The center of the object is currently the default frame origin for this body :



    Currently all the transforms are performed with this frame (so if I change the position co-ordinates the centre of the shaft is what is moved). How do I change this frame to be at one end of the shaft? (so that when I give positions of the tip, the tip is moved, and the rest of the shaft follows accordingly?)

    TL:DR - How to shift the body frame to its tip when the default is its centre?
     

    Attached Files:

  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,367
    First, double-check that the issue is not just a matter of "Center" vs "Pivot" mode in Unity. In the scene view, hit the Z key once or twice. A button at the top of the screen will toggle between "Center" and "Pivot" and the arrows gizmo attached to your object may move around. If you are in "Pivot" mode, the arrows gizmo should be aligned with whatever was at 0,0,0 in your mesh editor (Maya, Blender, etc.).

    If this doesn't help, you can either go back to your mesh editor and shift the model to a suitable origin, or you can create an Empty object in Unity and put your model inside it.
     
  3. ambareeshsrja16

    ambareeshsrja16

    Joined:
    Jun 26, 2019
    Posts:
    12
    @halley You were right, it was an issue of Centre vs Pivot. On pressing Z, the frame of ref has shifted to the correct tip. However, from the script end, does this mean that when I give transform.rotation or transform.position it automatically does about pivot always, and never centre? (which is what I want)
     
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,367
    Yes, the Transform is always relative to the Pivot. The Center mode is supposed to be an ease-of-use convenience feature of the Scene view editor but I find it is cumbersome and gets you into trouble more often than not.
     
  5. ambareeshsrja16

    ambareeshsrja16

    Joined:
    Jun 26, 2019
    Posts:
    12
    Thank you!