Raycast hitting.. itself?!

var display = "Sign Text Here";

function Update () {
	var hit : RaycastHit;
	if (Physics.Raycast (transform.position, Vector3.forward, hit, 1)) {
		print(hit.transform.name);
	}
}

I am using this code to determine if the character is standing in front of the sign. Unfortunately it would seem that the raycast is hitting… itself! As it returns “Sign” as soon as the game starts. Why is it doing such a thing?

Put the object on a different layer and have the raycast ignore that layer. (Although it seems to me that a trigger would be better for this sort of thing anyway.)

–Eric

Ooh, how true. I’ll just use a trigger. :stuck_out_tongue:

Triggers are still hit by raycasts, btw…

Oh, I know. I just put a trigger in front of it which to character collides with in place of a Raycast.