Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Bullet penetration methods - DBP

Author
Message
Baiame
18
Years of Service
User Offline
Joined: 8th May 2006
Location:
Posted: 22nd Jul 2006 07:35
Hello. Can anyone suggest a good method of simulating bullet penetration in DBP?

Now, what I need is basically for a bullet to be able to penetrate certain materials, slowing it down. Presently, I have bullets that travel at realistic speeds, and slow down as they travel through the air (the bullets' speed is the [time]*[velocity], and afterwards the velocity is lowered by [time]*[air friction coeffecient], while not realistic, it gets the job done). The bullets are destroyed once their velocity is below a certain amount.

As I said, the bullets travel at realistic speeds. This means that in one game loop they can travel about 15m. Of course, this means they completely miss any intervening obstacles. I thought this would be handled using raycasting (getting the bullet's position, moving it, then casting a ray from the old position to the new one).

However, the problem is incredibly complicated. I need to track the bullet's velocity as it penetrates objects, and in an actual game any number of such objects could be lined up and shot through. For the humans and vehicles in the game, the important thing is the amount of damage inflicted, which I thought would be in direct proportion to the bullet's veloicty. For physical objects, (I'm using Newton) this means the force applied is proportional to the velocity.

And the distance that the bullet travels through different materials is also important. A bullet going straight through the torso of an enemy would be slower than a bullet merely clipping his hand. The other reason why this is important is to ensure that the speed the game is running at does not determine the degree to which the bullet is slowed down.

A method I thought of is to raytrace, get information on all the objects from the bullet's start point and end point, then build another "world", which is basically one-dimensional (my bullets travel in straight lines). There would be different lengths across this line that are marked as transitionary between different materials (wood, air, flesh, etc.), and the velocity at every stage would be worked out (for as much of the line as is before an impenetrable material, which would be most things in the game). However, it seems to me that this method (as well as being difficult to program and implement) would be far too demanding, especially for DBPro. Also, I doubt this could be done with any built-in raytracing.

If anyone has any brilliant ideas, I'd love to hear them. Alternatively, if you know an external library that can do something like this, give my a link. Thanks.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Jul 2006 17:41 Edited at: 22nd Jul 2006 17:59
Im still not entirely clear on what you're asking, but if detecting collision with your bullets is the problem because they're going too fast, you'd project your intersection line from the bullet's old position to it's new position. If any intersection occurs inbetween these two points a collision occured. This way no matter what the speed of the bullet is you'll get the collision data.

Now from what I can gather, you need to figure out how fast the bullet is going when it hits something. This shouldn't be too much of a problem, since raycasting returns the distance to the intersection point, you get the distance behind the bullet that an intersection occured. The velocity of the bullet at the intersection point should be (if I remember my math correctly...)

Bullet Speed - (Distance/Speed Decrease Rate)

Where Bullet Speed is the current speed of the bullet, distance is the distance behind the bullet to the intersection, and speed decrease rate is how fast the bullet slows down per loop. That'll give you the speed of the bullet at the intersection, to work out the direction you can just return the bullet's angles.

Ill throw together a little demo in a sec'.


<EDIT>

Not sure what I was thinking, you dont need a formula, the speed the bullet was when it hits is fine. Here's some code;




Projects: Online CTF Game | Newcommer's Guide to FPS's
Baiame
18
Years of Service
User Offline
Joined: 8th May 2006
Location:
Posted: 23rd Jul 2006 13:41
Thanks for your help, Ruccus, but that's not what I'm trying to do.

I was aware of that method, as I said "I thought this would be handled using raycasting (getting the bullet's position, moving it, then casting a ray from the old position to the new one).".

What I'm trying to do, basically, is to measure a number of distances along a casted ray. I need to be able to work out the distance from the ray's start point of the 2 points on the line that represent an object that the ray intersected.
Baiame
18
Years of Service
User Offline
Joined: 8th May 2006
Location:
Posted: 26th Jul 2006 15:47
Nevermind, I worked it out a couple days ago.

I was looking through the feature list of Sparky's collision DLL, and it seems to have everything I need. I figure that if I cast 2 rays (from new to old, then old to new bullet positions), I could then work out the distances (total ray dist. -dist.2 -dist.1).
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 27th Jul 2006 00:24
Ummm.. DBPro has a command called INTERSECT OBJECT that finds the distance to the nearest collision...

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 27th Jul 2006 00:48
Sparky's is much faster, more efficient, and returns a lot more info like the angle of the normal of intersection, the position of the normal, the bounce direction, and lots more. Also has a lot more customability.


Projects: Online CTF Game | Newcommer's Guide to FPS's
Baiame
18
Years of Service
User Offline
Joined: 8th May 2006
Location:
Posted: 27th Jul 2006 17:35
^ Yep, and also, I require multiple collisions. INTERSECT OBJECT only does one.

Login to post a reply

Server time is: 2024-11-26 16:42:55
Your offset time is: 2024-11-26 16:42:55