Search Unity

How to change spring joint's resting length?

Discussion in 'Physics' started by green-giant, Oct 25, 2016.

  1. green-giant

    green-giant

    Joined:
    Jun 21, 2013
    Posts:
    43
    I want to set the resting length of a spring joint but I can't find a property for it.

    I found this documentation

    https://docs.unity3d.com/ScriptReference/SpringJoint.html - "The Spring attempts to maintain the distance it has when it starts out"

    Does this mean I can't change the rest length?

    Barring that ,I suppose, I could set my objects to proper distance apart, wait for Unity to pick up on the distance and then move them to where I actually want them. When exactly is "starts out" or rather when is the soonest I can change the objects position?

    EDIT: To be clear, the resting length I am referring to is the length which the spring is trying to push or pull to. In other words the length at which the spring will generate zero force
     
    Last edited: Oct 25, 2016
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    The resting length of a spring depends on its spring rate and how much force is applied on it. More force and/or less rate reduces the resting length. You may calculate the compression depth as: compression = force / rate

    Thus, specifying a resting length requires you to know the force the spring will be supporting at rest. Using the above equation you can then calculate the spring rate required for the spring to rest at that length.
     
  3. green-giant

    green-giant

    Joined:
    Jun 21, 2013
    Posts:
    43
    The resting length I am referring to is the length which the spring is trying to push or pull to. In other words the length at which the spring which generate zero force. If there are other forces involved like gravity, it will indeed change the length at which the mass will come to rest, but I don't care about that point.

    https://en.wikipedia.org/wiki/Hooke's_law