so i am making a gun and i wan't to add in bullet penetration so when the raycast hits the part i am going to start a raycast but so the raycast won't detect the part and stop the raycasting, i will make it so the raycast will ignore it but my only problem is, how will i detect once it is out of the part?
how to add in bullet penetration?
1 answer
It sounds like you want to figure out the depth of a part in a certain direction. This is similar to how you might cut a cake.
One easy way to approach this problem is to cast a second ray.
This ray will be cast in the opposite direction of the original ray. You can position this ray by going forward a few units from the hit point in the direction of the original ray. The distance between the hit point of the original ray and the hit point of the new ray is the effective "thickness" of the object in the arbitrary direction.
You can use this to determine whether or not a bullet should penetrate the object and how to modify its damage.
Note: How much further you position the new ray from the hit point of the original ray determines the max depth of penetration.
Note #2: In order to only detect intersections with the object in interest, use the ignore list
1 comment
AAAA IM SO SORRY I DIDN'T SEE THIS FOR A COUPLE DAYS
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
recreate the ray with a new position(hit), maybe using look vector
so how would i detect when the raycast exits the part?
Create A New Ray Right At the End Of where The Ray Hitted .
i know but once i create the ray how do i detect when the raycast is no longer in the part?
Why do that instead of just having it continue the distance? So if it hits is and something is tagged with "Penetrate" in CollectionService you let it go through it after drawing the bullet hole.
well what i am trying to do is for it to pretty much do that but i don't want unlimited penetration so i want it to detect when the raycast leaves the part
wait somebody said when i looked this up that if the raycast starts in the part and goes it will stop at the edge of the part imma try this cause if this works then my answer will be solved
aww doesn't work