I have been trying to build my project but I get this error repeatedly
using Microsoft.Win32;
using System.ComponentModel;
using UnityEngine;
public class Moviment : MonoBehaviour
{
public Rigidbody Player;
public GameManager Gm;
public Pause pausa;
public float sideForce = 2000f;
public bool GameEnded;
void FixedUpdate(){
GameEnded = Gm.GetComponent (“GameHasEnded”); //the error is here
if (GameEnded == false && pausa.IsPaused == false)
{
if (Input.GetKey(“a”)){
Player.AddForce(-sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey(“d”))
{
Player.AddForce(sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if(Player.position.y < -0.1f){
FindObjectOfType().EndGame();
}
}
if(FindObjectOfType().IsPaused == true)
{
GetComponent().velocity = Vector3.zero;
GetComponent().angularVelocity = Vector3.zero;
}
}
}
And one of the errors is :
NullReferenceException: Object reference not set to an instance of an object
at Moviment.FixedUpdate () [0x00001] in Assets\Scripts\Movement.cs:13
Double-check that you dragged/assigned a GameObject with a Rigidbody attached to it on the Player variable of this script in the Inspector of the Unity Editor.
I suspect that Player is null because it’s not assigned anything.