- Home /
what does this error mean ?
hey all can someone please explain what this error means ?
NullReferenceException UnityEngine.Camera.ScreenPointToRay (Vector3 position) (at C:/BuildAgent/work/f724c1acfee760b6/Runtime/ExportGenerated/Editor/Graphics.cs:674) Bullet .Update () (at Assets/FPSScripts/Bullet .js:7)
thank you in advance :)
Answer by CHPedersen · Jun 01, 2011 at 06:51 AM
@cidmodder is correct that this occurs when a reference is null, and you're trying to access either a method or a variable on it. It doesn't have to be the camera, however. It could also be the Vector3 which ScreenPointToRay takes as argument.
Thankfully, the exception is wonderfully polite in that it tells you precisely which class (Bullet) and which function (Update()) and at what line (7) the error occurred. Go through your code with Debug.Log() and write out all the variables that are used in that Update, and see which one of them was null. Then change the code to make sure it isn't null. :)
Answer by cidmodder · Jun 01, 2011 at 04:31 AM
I'm pretty sure thats an error where you haven't set the reference. It looks like the problem is at line 674 ".../Editor/Graphics.cs:674" maybe you don't have an object named bullet set up and linked in your hierarchy?
$$anonymous$$aybe you're using camera.ScreenPointToRay at line 674, but the camera variable is empty. If it's true, try to change it to Camera.main.ScreenPointToRay
Your answer
Follow this Question
Related Questions
Null Reference Exception Error. Modified Stats. Need Help. 1 Answer
NullReferenceException problem 2 Answers
NullReferenceException 1 Answer
3d Platform Tutorial Help 1 Answer
Error putting an object into an Array 0 Answers