Question by
Play Creatively · Sep 20, 2015 at 05:45 PM ·
null reference exceptioncamera.main
NullReferenceException to Camera.main.transform.position
This error comes up when I run my script:
NullReferenceException: Object reference not set to an instance of an object Movement.Start () (at Assets/Movement.cs:20)
my suspicion Is that It's not finding my camera, that the camera I'm using isn't the same as the one I'm referencing. Here's the line that received the error:
float camDistance = Vector3.Distance(transform.position, Camera.main.transform.position);
How can I resolve this?
Comment