Search Unity

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

Question Is it possible in any way to slow down a joint's movement?

Discussion in 'Physics' started by mellooow9, Nov 20, 2020.

  1. mellooow9


    Dec 25, 2019
    It seems impossible to do this. I need to be able to bring a joint close to a complete stop. (i have drive on it using target rotation) I was trying to do this with this code:

    Code (CSharp):
    1.  rigidBody.AddForce(rigidBody.mass,-rigidBody.velocity), ForceMode.Impulse);
    3. rigidBody.AddTorque(Vector3.Scale(rigidBody.inertiaTensor,-rigidBody.angularVelocity), ForceMode.Impulse);

    This should bring it to a complete stop, but it doesn't, it only slows it down, but not fully. And using any extra force causes it to glitch out. But this will work if there isn't any joint.

    Is there any possible way to slow the joint's movement?

    I can't use drag, it has the same problem as my code above. Even a very high drag will not slow the joint down any more than my code above does.

    I can't use the spring strength or dampening, because that will mess with the movement in other directions, making it sag.

    The only thing that I can think of is changing the target rotation. I'm making the joint slow down when it collides with a trigger, so I tried using quat.lerp between its rotation when it first collides, and the target rotation that i really want, with the 3rd parameter being how much i want to slow it down by.

    But it's a bit weird, since it will try to bounce back to where it first collided.

    I tried lerping between its current position and the target rotation i really want too, but it has accumulative effect that makes it continue whatever movement it has, and I don't really know a way around that.

    Is there any better way of doing this?