Roll-A-Ball character not moving

Hi there, I am totally new to unity, and I don’t know what on earth am I doing. So, I was following the Roll-a-Ball tutorial game when I came up with a problem (1. Environment and Player - Moving the Player). The ball was not moving! I have this script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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

and my settings:

I don’t see anything to do with “Player Controller” on here

Also, I see this when I press the file in the bottom left corner of the image above:

Can anybody tell me what is wrong?

Add your playercontroller to your ball…Might have missed this step. I haven’t seen the tutorial.

1 Like

How do I do that?

Either drag the script onto the player game object or click that “Add Component” button and find your script that way.

Welcome to Unity!

Thanks! I’ve done that but it still fails to work

Keep following the tutorial :slight_smile: Welcome to Unity…
Here is the full script from the webpage – your script was missing speed, and that could be why it’s not working (well) for you.

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

In the scene view, click on the player and look at the speed variable in the inspector. Try setting it to 10 and hit play :slight_smile: