Hello,
Beginner Unity user here,
I am currently following the official Unity Roll A Ball tutorial, and have gotten stuck. I have copied all of the code exactly in episode 2 of the tutorial, and for some reason in the console it spits out the error “The referenced script on this behaviour (gameobject ‘player’) is missing”. I have no idea why this is happening. I have googled the problem and from it I have done the following things: Reimport All (the Assets folder), pressed F8 in Monodevelop (nothing happened) and have also re written all of the code. Yes, I do have a Rigidbody and I have checked many times and I’m like 99% sure I have everything written exactly correct. Sorry if this is a really stupid question with an easy answer, as I said I am new to Unity. PLEASE HELP!
The following is the code I have used in the script ‘Player Movement’, a script component of the sphere object ‘Player’:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Vertical”);
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
}
(for some reason i cant seem to able to space things out on here, but I assure you it looks exactly the same as the tutorial.)