- Home /
Stopping rigid body semi-instantly
I'm using following snippet to stop player after moving in order to make my controls more responsive. Character is physics-controlled.
if ((Input.GetAxisRaw("Vertical")==0)&&(Input.GetAxisRaw("Horizontal")==0) && (isGrounded) && (jumping<1)){
GetComponent<Rigidbody>().velocity = Vector3.zero;
}
And it works good. Too good in fact - as a matter of fact, I still want it to have some inertia, but not too much, about 3-10 frames or so. And now: When I'm using physics alone, inertia is always too high, it takes SECONDS for character to stop, no matter what I try and when I'm using above snippet, it stops instantly which is what I don't want either.
Possibly answers your question: http://answers.unity3d.com/questions/714870/how-to-do-inertia-damping.html
Answer by FortisVenaliter · Aug 21, 2015 at 04:07 PM
If you're using a rigidbody, you can just drastically increase the drag when that if() evaluates to true. You'll have to play with the values, but you should be able to get the result you want. Just remember to turn it back down when moving.
Your answer
Follow this Question
Related Questions
Player is Speeding up in collisions 0 Answers
How do you move a character with physics when using Animator.setInteger to play the animations? 0 Answers
Stopping my player from moving when hitting a wall. 5 Answers
Character controller jittering up and down 2 Answers
Slope limiting with Rigidbody 0 Answers