I am using a raycast script but it says "Null Referance Exeption Object referance not set to an instance of an object", and doesn't print anything
How do i fix this
function Update () {
var foundHit : boolean = false;
var hit : RaycastHit;
if (Input.GetButton("Fire1")){
if (Physics.Raycast(transform.positon, transform.forward))
print("YES");
else
print("NO");
}
}
↧