Roll-A-Ball not working.

I’m trying to the the roll-a-ball tutorial. I’ve done everything correctly, but when I try to use the arrow keys to roll the ball around, it doesn’t work.

The code:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public float speed;

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 * speed);
}

}

I don’t see anything wrong in the script; there must be something else.

You should ask on the dedicated forums thread: https://community.unity.com/t5/Teaching/Roll-a-ball-Tutorial-Q-A/m-p/2190828#U2190828

The public float speed is defaulted to 0, but can be set in the Unity inspector. Note: changing the value in code won’t do anything, make sure you change it in the inspector!

rb = gameObject.GetComponent ();
Back when the tutorial was made, the way you did it was correct. Now you have to have gameObject behind it.