- Home /
Make Certain Object's Raycasts Ignore Certain Colliders
I have a prefabbed pitchfork that casts a ray. Once the pitchfork hits a collider, I want the pitchfork to stop detecting raycasts to that collider. However, I still want other pitchforks to have their rays hit that collider. I don't see how I can correctly use layers for this, as if I switch the layer of the collider hit by the raycast to a layer like "IgnoreRaycasts" then all the other pitchforks will no longer have their ray hit the collider.
.
Current I have a custom class which stores the gameobject and the hit collider, and each time the prefabbed object's rays hits and object it goes through a list of this class and check each and every gameobject to see if they match, and if they don't, then add it. This is very inefficient and I deserve a spanking.
.
Please help,
.
Thanks .
Also how do I add line spacing in Unity Answer? I can only make line breaks if I add a character and THEN add 2 spaces and press enter.
.
Thanks