- I am getting the error below appearing in my console:
NullReferenceException: Object reference not set to an instance of an
This error is caused when an object is trying to be used by a script but does not refer to an instance of an object.
To fix this example we can acquire a reference to an instance of the script using GameObject.Find to find the object it is attached to. We then use GetComponent to find the script component we want a reference to.
You can also double click the error to take you to the line of script where the error is occurring.
From there you can trace each object back to where they are assigned (if they have been assigned).