3rd person shooter shoot script error, I am lost. Null Reference Exception error.
after the shoot script cleanup section I am getting an error on line 27, the Ray rayOrigin ... line. it states that object reference not set to an instance of an object.
would anyone be able to point out what is the problem?
Vector3 center = new Vector3(0.5f, 0.5f, 0);
Ray rayOrigin = Camera.main.ViewportPointToRay(center); (this line is giving me an NullReferenceException error)
if (Physics.Raycast(rayOrigin, out hitInfo))
Debug.Log("Hit: " + hitInfo.collider.name);
Health health = hitInfo.collider.GetComponent<Health>();
if (health != null)
Thanks for your help.