Physics2D: how to add friction?

Hello,
I have a Ball sprite and a Floor sprite. The Ball has a Rigidbody 2D and is controlled by the player with this script:

using UnityEngine;
using System.Collections;

public class Ball : MonoBehaviour {

	public float xSpeed = 4;
	
	void FixedUpdate () {
		float inputX = Input.GetAxis ("Horizontal");
		if (inputX != 0)
		{
			rigidbody2D.AddForce(new Vector2(inputX * xSpeed, 0));
		}
	}
}

When the Ball moves on the Floor it doesn’t decelerate. How can I add friction to the Ball on the Floor so that it decelerates till stopping, after a force has been applied to it?

Thank you in advance! :slight_smile:

Create a Physics2D material and then apply that physics material to your floor.
17876-physics2d.png
As you see in the picture, it allows you to define friction.

Now to make it work the way you want, just change the linear drag of the Ball’s rigidbody to something other than 0 and Voila! :slight_smile: