NullReferenceException

I keep getting this after I changed the code for this lesson.

NullReferenceException: Object reference not set to an instance of an object

tried everything I know to do to fix it. I’ve even deleted the player reference and dropped in a new capsule but still the same thing.

I figured it out after 2 hours of researching.

The line Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); references the main camera. I had deleted my main camera and therefore lost the MainCamera tag. It was as simple as that.

Hope that helps anyone else that runs into this problem.

Good job on getting that sorted!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms