Myth
1
Hi,
Why is this spitting a null reference at me?
Any help is greatly appreciated!
var team : String = "blue";
function Update ()
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, Vector3.forward, 2))
{
hit.collider.SendMessage("Capture", team, SendMessageOptions.DontRequireReceiver);
}
}
KeithK
2
You need to pass your "hit" variable into Physics.Raycast(), it's inside that function that it gets assigned. At the moment you declare it, where it starts off as null and leave it like that.
Try this:
Physics.Raycast (transform.position, Vector3.forward, hit, 2)