Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Object reference not set to an instance of an object [HELP!]

$
0
0
I'm getting this error but I have no clue whats wrong with my code. I am not getting any compile errors, but errors when I start the game. The error is: NullReferenceException: Object reference not set to an instance of an object PlayerCamera.CameraMovement () (at Assets/Scripts/PlayerCamera.cs:185) PlayerCamera.LateUpdate () (at Assets/Scripts/PlayerCamera.cs:141) Here is the code that gives me the error: public void CameraMovement() { if (playerController.aim) { Camera.main.fieldOfView = Mathf.Lerp (Camera.main.fieldOfView, zoomFOV, _deltaTime * lerpSpeed); _camDir = (aimDirection.x * target.forward) + (aimDirection.z * target.right); _targetHeight = normalAimHeight; _targetDistance = normalAimDistance; } else { Camera.main.fieldOfView = Mathf.Lerp (Camera.main.fieldOfView, normalFOV, _deltaTime * lerpSpeed); //Error on this line _camDir = (normalDirection.x * target.forward) + (normalDirection.z * target.right); _targetHeight = normalHeight; _targetDistance = normalDistance; }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>