System.NullReferenceException: Object reference not set to an instance of an object at playercontroller.FixedUpdate () [0x00024] in /Users/Cory/Desktop/Unity/Roll a Ball/Assets/scripts/playercontroller.cs:20

What have I missed? I’ve been staring at this for ages.

using UnityEngine;
using System.Collections;

public class playercontroller : MonoBehaviour {

private Rigidbody rb;

void Start ()
{
	rb = GetComponent<Rigidbody>();
}

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

	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		
	rb.AddForce (movement);
}

}

Never mind it just started working. Perhaps I hadn’t updated it properly by saving.