How do I stop my character feeling like they're on ice using RigidBody2D Velocity

I am currently using RB2D velocity for movement but I can’t make it stop sliding after I’ve finished pressing the button. It feels like the Ice level from Mario. How do I stop my character sliding everywhere?

My code is:

void Movement() {

		if (Input.GetAxisRaw ("Horizontal") > 0.1) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (speed, GetComponent<Rigidbody2D> ().velocity.y);

		}
		if (Input.GetAxisRaw ("Horizontal") < -0.1) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (-speed, GetComponent<Rigidbody2D> ().velocity.y);

		}
		if (Input.GetAxisRaw ("Vertical") > 0.5 && grounded) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (GetComponent<Rigidbody2D> ().velocity.x, jumpHeight);

		}
	}

My speed is set to 5, jumpHeight is 10 and I have both box collider and RigidBody2D on my player

Thanks for any help in advance

Fixed this thanks to cjf93 on StackOverflow

New code is

void Movement() {

		if (Input.GetAxisRaw ("Horizontal") > 0.1) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (speed, GetComponent<Rigidbody2D> ().velocity.y);

		} else if (Input.GetAxisRaw ("Horizontal") < -0.1) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (-speed, GetComponent<Rigidbody2D> ().velocity.y);

		} else if (Input.GetAxisRaw("Horizontal") == 0 && grounded) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, GetComponent<Rigidbody2D> ().velocity.y);

		}


		if (Input.GetAxisRaw ("Vertical") > 0.5 && grounded) {

			GetComponent<Rigidbody2D> ().velocity = new Vector2 (GetComponent<Rigidbody2D> ().velocity.x, jumpHeight);

		}

	}

This makes the character floaty in the air and stay still whilst on the ground after you stop pressing the button :slight_smile: