How to delete a raycast hit

What I’m trying to ask is how do I make a raycast stop on a specific object. For example I wanna be able to shoot through a non-bulletproof item, but force the raycast to stop once it hits a bulletproof object. I don’t want to just ignore the layer of non bullet proof items as I would still like to instantiate a bullet hole and particles where the raycast is going through. Thanks in advance!

I forget the exact syntax, but one of the ray cast methods returns all intersections. It would then be up to you to sort them by distance and decide which ones block bullets, or do whatever.

1 Like

What about using RaycastAll? You can sort the results by distance and then work your way through the results.

Another approach would be to raycast, do what you need and raycast again from the hitposition if it is not bulletproof (you may want still want to ignore the ones you’ve already hit).

The latter can be useful if you want to implement simulated richochets(?).

1 Like