- Home /
Raycast that ignores object with certain tags?
Hi, im trying to make a turret script that detects players through raycasting. I got the raycast part working, but how do I make the raycast ignore certain objects with certain tags? The "ignore raycast" layer worked well, but it ignores every raycast made on it by my turret or other stuff like my player. I just want the object to ignore the raycast made by my turret. How do i do this with tags in javascript? Thanks!
Answer by Kona · Feb 19, 2011 at 06:10 AM
:) Yes that's possible, found this answer awhile ago and it works well:
Answer by user-3061 (yahoo) · Feb 19, 2011 at 08:23 AM
I'm trying to use what you gave me, but i have no idea why it wont work. here's my code so far :
if (hit.transform.tag == "Turret") {
Physics.IgnoreCollision(hit.collider, collider);
}
can anyone tell me where i did wrong?
Isn't the turret raycasting to the player? In that case, does the player use the "Turret" tag? I'd tend to believe its the other way around, possibly?