The Roll-A-Ball tutorial doesn't work with Unity 5.

I have just started to use Unity, and I went on the first game tutorial (Roll-A-Ball) to learn some of the basics. However, once I got on to making the script to move the character, an error came up on my code that didn’t come up on the tutorial.

Here is the code:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");

	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

	*Rigidbody.AddForce (movement);* 
}

}

However, on line 13 (the line with asterisks) it says “An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)'”.

As I have just started Unity, I have no idea how to do this, nor can I find anything on the website itself about this.

Can you please help me fix this.

This has been asked SOoooo many times, it will benefit you to search the answers first. Unity 5 made some breaking changes and you need to apply them. If the script already existed it would offer to “try” and convert/fix to the new logic.

You need to get the component, you can do this inline or get the reference in something like the Start method and use the reference going forward. I will leave the last for you to research.

Change line 13 to:

GetComponent<Rigidbody>().AddForce(movement);

Rightbody as a component should exist on the same game object that this script you’ve posted is attached to. GetComponent will search by type and return the first type of Rigidbody it finds, then invoke the AddForce method with the Vector3 variable “movement”.