Search Unity

Angle of HingeJoint with connected body

Discussion in 'Physics' started by silentslack, Nov 27, 2016.

  1. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    Hi,

    How can I get the relative angle a HingeJoint has rotated from its initial rotation if the joint has a connected body? If the joint stays shut but the connected body moves, HingeJoint.angle seems to change.

    Thanks!
     
    ifisch likes this.
  2. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    Still after this answer. How can I tell a door has shut for instance if the wall it's attached to (its connected body) moves? I assumed HingeJoint.angle would tell me this but it isn't relative to its own joint it seems.
     
    ifisch likes this.
  3. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    I'm hoping a picture may help my cause! This is my box with a lid. It uses a hinge joint to open the lid.



    How can I get the angle from initial (closed) if the box Rigidbody moves around? Should Hinge.Angle be the relative angle because that is not the case.

    Thanks!
     
  4. Fu11English

    Fu11English

    Joined:
    Feb 27, 2012
    Posts:
    258
    Why not just measure the angle between the two transforms (hingeTransform and wallTransform) using Vector3.Angle(). ?
     
  5. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    Well they might not be pointing in the same direction at initial but I guess I could calculate the initial delta. Will give that a shot. But wondering if Hinge.Angle is broken?
     
    ifisch likes this.
  6. ifisch

    ifisch

    Joined:
    Jul 15, 2012
    Posts:
    35
    I agree with you. This is still a problem 3 years later. Can someone from the Unity team please look into this?