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

Angle of ConfigurableJoint

Discussion in 'Physics' started by UnitedBluff, Jul 12, 2015.

  1. UnitedBluff

    UnitedBluff

    Joined:
    Apr 19, 2015
    Posts:
    15
    Hello all.
    I'm looking for a way to read the current rotation around a ConfigurableJoints axis.
    I was hoping that there would be a joint.GetAngle(axis) method, but the world is not that simple, it seems.
     
  2. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    There is no joint.GetAngle, indeed, but you can still figure out the rotated angle of a joint this way:

    * Store the initial angle between the joint 'host' object's transform.up (or whichever axis is orthogonal to your joint) and the same axis on the attached object
    * Get the angle between those same two axes on an update loop
    * subtract the initial angle

    That should give you a persistent angle between both jointed objects, relative to their starting orientations.

    Cheers