Hello,
I’m trying to get a gameObject from a raycast but i get an NullReferenceError on the second line (I got this code from the scripting reference for editing it later).
if(Input.GetKeyUp(KeyCode.Mouse0)) {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition); // < Error?
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
Debug.DrawLine (ray.origin, hit.point);
}
}