I'm having a problem trying to get a game object to move to the location of my mouse pointer when I click. I used the script located at http://docs.unity3d.com/Manual/nav-MoveToClickPoint.html
I'm working in JavaScript and I copy and pasted the exact script.
I can launch Play mode but when I click anywhere to move the object, I get an error that says NullReferenceException: Object referenced not set to an instance of an object. It says it's on line 13, which is this:
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit, 100))
I created a nav mesh, baked it, put a NavAgent component on my game object, and still nothing.
I'm not sure why, but does someone know if the key words have changed or something?
↧