x


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 :)

more ▼

asked May 13 '12 at 10:15 PM

Inan Evin gravatar image

Inan Evin
166 37 58 64

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use 'RaycastAll'- it returns an array of hits that you can use in this fashion.

more ▼

answered May 13 '12 at 10:51 PM

syclamoth gravatar image

syclamoth
14.8k 7 15 80

thanks that works fine :). But another problem occured, it doesn't stop. Is there any way to stop the raycast in if statement ?

May 14 '12 at 08:41 PM Inan Evin

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.

May 15 '12 at 02:19 AM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1528
x308
x17
x2

asked: May 13 '12 at 10:15 PM

Seen: 577 times

Last Updated: May 15 '12 at 02:19 AM