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

Simple spring joint 2D, Oscillations damped with Damping Ratio = 0

Discussion in '2D' started by JamesPomme, Dec 2, 2014.

  1. JamesPomme

    JamesPomme

    Joined:
    Nov 18, 2014
    Posts:
    9
    Hello,

    I try to have a sprite (2D project) attached to another gameobject via a spring with Damping ratio =0. I expected to get continuously oscillating system (no linear/angular drag) but It is not the case.
    I get like 10 oscillations before my spring stop.
    How can I get an ideal spring in unity?

    I'm sorry if this problem is related to a common beginner (that I am) mistake but I haven't find any answer in this forum or googling it.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Unfortunately the 2D physics spring (which uses Box2Ds bsDistanceJoint) won't give you a spring that oscillates forever. Even at damping ratio of zero, there is still damping implicit in the calculations within Box2D.

    Erin Catto who wrote Box2D explains this in detail here: http://box2d.org/forum/viewtopic.php?f=3&t=7017&hilit=spring+no+damping

    It is of course possible for you to perform these calculations yourself and apply the appropriate forces.
     
  3. JamesPomme

    JamesPomme

    Joined:
    Nov 18, 2014
    Posts:
    9
    Thank you very much for your reply.

    Indeed, it won't be difficult to add a "spring force" by hand but I was affraid to do something wrong or having missed something.

    thanks again
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Not a problem, sorry it doesn't give you what you need out of the box.