- Home /
Raycasts hit triggers disabled - force collision for specific raycast
Hello,
I'm having a slight issue with my Unity project. The vast majority of the time, I do not want any Raycasts to hit any triggers, and the game engine is built around having the Physics option "Raycasts hit triggers" turned off. However, I now find I have a specific case where I absolutely need a raycast to detect a trigger volume. However, it now seems that I can't do this. I thought about temporarily re-enabling the option, but there doesn't even seem to be a way to do that. Is there any way I can do this without restructuring my entire project?
Answer by iHaveReturnd · Feb 18, 2014 at 02:41 PM
There might be a way to enable it specifically how you're talking about, but I don't know if there is.
Alternatively though, you could turn that physics option on, and set the layer for all of your triggers to be Ignore Raycast. That way the raycasts can still hit colliders you want them to. You can change an object's layer at runtime as well, so if you needed it to be disabled (ignore raycast) most of the time, you could just swap it when you want it enabled then send it back.
Hope that helps!
Oh sure, I could do that, but note that I specified that this option is integral to the structure of my project, and it's not exactly small. I'm using layers for other things, so it would need to be completely restructured for that to work. It's just not a viable option.