Sign in to follow this  
Alfederate

Raycasting Bullet Penetration?

Recommended Posts

Hello, in my game I'm trying to implement bullet penetration through objects using raycasting. mjiprTH.png

 

The elements I know how to determine are the Start Point, Enter Point, and Surface Normal. The problem I have is how to find the Exit Point. With that I can calculate the Depth/Penetration Distance and continue the ray in the same direction. Does anyone know how I can find the Exit Point, knowing the direction of the ray, enter point, surface normal, and size and position of the object? I appreciate any help.

Share this post


Link to post
Share on other sites

How are you doing the ray-casting? You just want to issue a ray-cast query that finds all collisions along the ray instead of just the first one.

 

Alternatively, after finding the "enter point" collision, start 2nd ray cast from that position in the same direction (or offset along the ray direction by some small bias value), and you'll get the exit point collision. Then start a 3rd cay cast from that position in the same direction to continue the bullet's path.

Share this post


Link to post
Share on other sites

How are you doing the ray-casting? You just want to issue a ray-cast query that finds all collisions along the ray instead of just the first one.

 

Alternatively, after finding the "enter point" collision, start 2nd ray cast from that position in the same direction (or offset along the ray direction by some small bias value), and you'll get the exit point collision. Then start a 3rd cay cast from that position in the same direction to continue the bullet's path.

 

With the engine I'm using, the only thing the ray does is cast from A to B, returning position and surface normal of the object it hit, but only detecting if it hit the outside of the object.

 

However, I did manage to fix the problem by surrounding the block with invisible plates which the ray hit and determined the exit point.

 

Thank you for the help  :wink:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this