Next, make a new script and attach it to the character and add the following code inside your class (note there is an improved version at the end of this tutorial so if you’re just copy and pasting, scroll down first – although I strongly suggest you read the article to understand what it does): Rigidbody2D body float horizontal float vertical public float runSpeed = 20.0f void Start () First, attach a Rigidbody2D component to your 2D character, and turn the gravity scale down to 0.