I have an object that I move using this function
public void StartWalk(float direction)
{
movement = new Vector2(this.speed.x * direction, this.rigidbody2D.velocity.y);
}
private void FixedUpdate()
{
rigidbody2D.velocity = movement;
}
It works fine but problem is that when I stop moving it, the object starts slowing down until it stops. This slow down takes very long and it travel a long distance until it stops. How can I make it stop faster? I don’t want it to stop instantly, just faster, like if the surface was not like an ice 
2 Answers
2
The answer here is incorrect. The code shown by the OP is of very simple 2D sprite movement. The issue described stems from keyboard input that simulates the “return to center” of a joystick. A quick check of the default settings in:
Player Settings → Input → Horizontal / Vertical
…should reveal that the Gravity and Sensitivity of the keypress settings for Horz and Vert are set to 3 while other keys for “instant” actions like a Fire Button are set to 1000 !
The “gliding” being seen is the interpolation between the key being released and the system returning input to zero over a short amoutn of time. *(Where is this time configured??).
Go in and set Gravity and Sensitivty to 1000 and you’ll see the sprite will now instantly stop when you release a keypress direction! Personally, I like a setting of 100 (so there’s a little slow-down but not enough to feel “sloppy”).
Modifying drag, friction etc like the accepted answer suggests will ALSO impact velocity and all other physics settings you already have related to the player movement and thus requires lots of re-tweaking to get everything right.
Assuming you don’t have any other forces on it, just upping the ‘Linear Drag’ in the Rigidbody2D on the object should do the job. You might also consider creating and setting physic2D materials on the Collider2Ds of the sliding object and the surface. You can define the friction and bounciness for both colliders.
friction does the job, there is no linear drag in 2d it seems
– petrbena