I’m trying to do the 2D UFO tutorial, and every time I enter in my code it says “The referenced ‘player’ game object is missing” And whenever I try to test it, the player doesn’t move. This is my code.
using System.Collections;
using UnityEngine;
public class CompletePlayerController : MonoBehaviour {
public float speed;
private Rigidbody2D rb2d;
// Use this for initialization
void Start () {
rb2d = GetComponent<Rigidbody2D> ();
}
// Update is called once per frame
void FixedUpdate () {
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector2 movement = new Vector2 (moveHorizontal, moveVertical);
rb2d.AddForce (movement * speed);
}