Search Unity

Question Is there a way to access force level on a DistanceJoint2D?

Discussion in 'Physics' started by Relo999, Jan 11, 2022.

  1. Relo999

    Relo999

    Joined:
    Dec 22, 2015
    Posts:
    24
    Is there a way to access force level on a DistanceJoint2D? I can see it's used on it's break limit but is I can't find some way to directly access that. As I'd like to manually break it (as deletion of the DistanceJoint2D isn't ideal in my situation) as well as show the force on the joint with a color.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    Did you look at the API docs? It's all listed there and referred to in the docs for the properties you mention i.e. breakForce.

    All joints (Joint2D) inherit the properties reactionForce and reactionTorque as well as methods to get the same but allow you to also specify an explicit time-step (GetReactionForce and GetReactionTorque)

    The breakForce and breakTorque thresholds you refer to just compare against the reaction force/torque above given the current simulation time-step so yes, you can do this yourself.
     
    Relo999 likes this.
  3. Relo999

    Relo999

    Joined:
    Dec 22, 2015
    Posts:
    24
    Thanks, I did look at the API. However I didn't make the connection to the more generic Joint2D, just looked at the DistanceJoint2D. In hindsight it makes a lot of sense.
     
    MelvMay likes this.
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    Np!

    In-case you didn't know a FYI is that if you click on the property/method that's inherited, it'll take you to the API type where it's implemented too.