Reputation: 3
I am trying to use a boollean from another script. But I get the error message "Object reference not set to an instance of an object CameraController.Update()". Any ideas?
public Controller mPlayer;
void start()
{mPlayer = GameObject.Find("Player").GetComponent<Controller>();}
void Update()
if (mPlayer.testScript)
{Do Stuff}
Upvotes: 0
Views: 133
Reputation: 385
The error is clear
"Object reference not set to an instance of an object CameraController.Update()".
you are trying to use a null object as if it was a properly referenced object. Most of the time, when you try to assign value into object, and if the value is null, then this kind of exception occur.
try debug the code line by line and find the null value occur.
Upvotes: 1
Reputation: 4049
You need to be careful of case sensitivity. It's (capital S) Start()
It's:
void Start()
{
mPlayer = GameObject.Find("Player").GetComponent<Controller>();
}
Upvotes: 1