Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

broken hinge joint

Discussion in 'Scripting' started by Brian-Kehrer, May 8, 2007.

  1. Brian-Kehrer

    Brian-Kehrer

    Joined:
    Nov 7, 2006
    Posts:
    411
    is there a property to say if a hinge joint has been broken?

    Basically I want to do

    if(joint is broken){
    do something;
    }
     
  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Code (csharp):
    1.  
    2. if(!joint.connectedBody)
    3. {
    4.   ...
    5. }
    6.  
    I don't know if this works the way you want it to but the connected body variable is there.
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,758
    No. When a joint breaks, it no longer exists. So the way to check for that is simply:
    Code (csharp):
    1.  
    2. if (joint) {
    3. ....
    4. }
    5.  
    If connectedBody doesn't exist, the joint is attached to a point in space.