How to remove inertia from objects?

I’m quite new to unity and programing and I have run into some issues with my game, im using AddForce on my player to move but after pressing for example “a” to move to the left iwant it to just move a little bit and then stop, the problem is that it keeps moving for a bit until it stops, my questions is how do I remove the inertia so that it only moves when I’m holding the key down and then immediately stops when i release it.

I believe if you add something like the following you should get your desired result:

If (Input.GetKey(KeyCode.a) || Input.GetKey(KeyCode.w)) //continue for all movement keys
{
    //move logic here
}

I’m quite new myself so apologies if I’ve made a mistake, but I just did this literally last night and it worked great for me!

Increase the rigidbody’s drag. This will make it lose linear velocity faster over time, eventually coming to a stop.

Increasing the angular drag does the same, but for angular velocity.

Set the rigidbody velocity directly, don’t use forces to modify the velocity indirectly. You can then stop it immediately by setting the velocity to zero. You can control both the linear and angular velocities like this.

4 Likes