- Home /
Simple Raycast Penetration
Hello everyone, I need a lead way or some kind of an explanation about bullet penetration. I simply have a raycast shooting code with damage, it works fine. I want it to penetrate from some objects like wood. I thought a way like this, for example, if hit gameObject has a tag called "wood" ; make a bullet decal on hit position and damage it & continue to search for any other colliders from the same direction, if find any make a decal on it & damage it too. But I couldn't figure out how to do that. Or is there any other logic or explanation about bullet penetration with raycast shooting ? Thanks :)
Answer by syclamoth · May 13, 2012 at 10:51 PM
Use 'RaycastAll'- it returns an array of hits that you can use in this fashion.
thanks that works fine :). But another problem occured, it doesn't stop. Is there any way to stop the raycast in if statement ?
Yes, RaycastAll has a 'distance' paramater that you can implement- by default it is set to infinity, but you can change that to anything you like. Alternatively, if you don't know the distance before the raycast is shot, you can calculate your desired maximum distance and then simply ignore any that are from further away than that.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071439im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Penetration weapon needs to find all objects it passes through 1 Answer
Using Raycast to shoot a bullet sometimes goes through objects 0 Answers
Hit enemy life with raycast 1 Answer
Bullet Effect 2 Answers
How do I create bullet hole for my gun? 0 Answers