Roll a ball – sphere not moving

Am complete novice and using Unity for very first time plus grappling with C#.
Have followed the ‘ Moving the Player” tutorial closely but am falling at first hurdle. My sphere does not move. I have clicked on ‘Game’ and then clicked the play button but still no moment.

I have;
. Double-checked the script (see below)
. Checked my UI reflected that of the tutorial
. Saved the project and closed down Unity and re-launched

Any guidance appreciated.
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);
}

}

3 Answers

3

It is “FixedUpdate () {…}” not “fixedUpdate () {…}”

You should check for errors more often :slight_smile:

Have you attached this script to sphere?

Yes … see that. Learnt a ton since I asked this question in Feb :0) Many thanks.