Search Unity

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

Question How can I stop a 2D swinging rope?

Discussion in 'Physics' started by Pietrofonix, Oct 14, 2023.

  1. Pietrofonix

    Pietrofonix

    Joined:
    Aug 1, 2020
    Posts:
    54
    Hi guys, I made a 2D rope following this video:

    Everything works fine except I can't stop the swinging of it when I move it. It's made by a parent with a static Rigidbody 2D and a Distance Joint 2D, while all the children have a Rigidbody 2D and a Hinge Joint 2D. I tried to activate the motor inside all Hinge Joints 2D and modify the speed and force of it, but it didn't work.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,161
    You're not describing what you want very well at all. Please be specific on what you mean by "Stop a 2D swinging rope". Stop it implies instantly which makes no sense for a rope with gravity. Slow it down over time? Please be specific. If you want to slow over time then use the linear/drag options you have as you normally would any Rigidbody2D.

    What would motors do here? I don't understand.
     
  3. Pietrofonix

    Pietrofonix

    Joined:
    Aug 1, 2020
    Posts:
    54
    Yes I want to slow it down over time. Do I have to increase the linear/drag options of all children? Would this allow me to decide how fast the rope has to stop?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,161
    There's no rule on how to do it. Do a few, do all of them but if you want it to slow down then you need something to damp the momentum; this is what drag is. Either than or damp it yourself by reducing the speed.

    In the end, no need to ask, just try it, it takes seconds to try. :)

    Not sure what you mean by this. It'll slow down over time, it won't tell you it'll be at rest is 6 seconds for example. The rope is a system and it'll get far too complex to calculate such things easily. It'll be a case of try and see if you get the correct results.