- Home /
Object reference not set to an instance of an object
I'm trying to get the collision detection to work but i'm getting this when i try and make a new instance. NullReferenceException: Object reference not set to an instance of an object BasicControl.Update () (at Assets/BasicControl.cs:15)
Answer by robertbu · Jun 14, 2014 at 09:57 PM
Your code is not the way to detect a collision. You need to look at OnCollisionEnter(). Since you did not get your collision from a callback in Unity, the gameObject in the collision will be null or undefined. That is why you are getting the error.
For future posts, please past your code into the question. After pasting, select your code and use the 101/010 button to format the code.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to build a road? 1 Answer
Having trouble with grid movement 1 Answer
How do i fix Error CS0029? 1 Answer