I’m instantiating two objects on the scene. Each of this objetc have a similar script
but when I click the object I gete the NullReferenceException. How can I fix it?1 Answer
1I assume only OnMouseDown is executed when you click on the object. So there are 3 possibilities:
- GameManager.gm is null
- If GameManager.gm is a property, some code in GameManager.gm’s GET is throwing the exception.
- An object reference used in turnPos function is null.
Unity’s console window should tell you the name of the last function called before the exception was thrown and also the line number.
