I’m getting a “NullRefrenceException” error with to following line of code:
mousePos = camera.Main.ScreenToWorldPoint(Input.mousePosition);
(playerPos is simply a var, defined in a different spot in the script)
Anyone know why?
Thanks in advance.
I’m getting a “NullRefrenceException” error with to following line of code:
mousePos = camera.Main.ScreenToWorldPoint(Input.mousePosition);
(playerPos is simply a var, defined in a different spot in the script)
Anyone know why?
Thanks in advance.
Use Camera.main (capitalize Camera, lower main) [corrected]
Actually that did not work; I still get the error. -_-
– anon81475095Main is not suppose to be capitalized. So: Camera.main
– anon81475095Actually it's <a href="http://unity3d.com/support/documentation/ScriptReference/Camera-main.html">Camera.main</a>. In the future please check the documentation first. That are some very trivial mistakes... (ps, and be careful what you post as answer to such questions, it could be wrong ;) )
– Bunny83My apologies for propagating error.
– DaveA