Archived

This topic is now archived and is closed to further replies.

Aargyle

Strategy for handling bullet hit detection

Recommended Posts

Aargyle    122
I was wondering if anyone had some general strategies for doing fast bullet hit detection (line vs world). For normal objects, an octree or something similar eliminates most potential colliders pretty fast. But a line is not a small object, and it seems to always go through an entire dense region of my octree, causing a gazillion low level detections to happen, which makes it very slow. Now, considering that every FPS out there has fast easy bullet collision detection, how the heck do they do it? I''m picturing something like an outdoor location, where just finding out where the bullet hits the heightmapped ground makes me test against every polygon under the line (bad). Also, what is faster, line vs box or line vs sphere? Darn those lines! lol. Maybe I should make bullets small spheres that move fast so that normal octree stuff works. But bullets move a long distance each frame making... a line!!! Grr.

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
Those fast FPS''s are almost certainly doing something like the octree approach, but with the collision world optimized so that there are not all that many really dense regions in the octree.

Line vs. sphere would be faster.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Bullets could be given finite speed, too. This would greatly limit the area you have to check for collisions, and be more realistic. While you are at it, you could even have them decelerate from air resistance, and accelerate from gravity. Delta Force is a game that allows you to see these effects fairly well when using tracers.

Share this post


Link to post
Share on other sites
oliii    2196
yeah, put some dynamics to your bullets, and trace from the last position to the next frame position. Don''t model them as a single point. Then you can use all sorts of dynamics effects, like the bullet''s muzzle velocity, gravity, air friction, water friction, wind, energy dissipated at the point of impact (weight of bullet times velocity), ricochets, ect... And you can re-use the same code for rockets and missiles and other projectiles. That''s the way I would probably go, the computers and consoles nowadays can do thousands of those things in the blink of a transistor.

Most games don''t bother though. They just trace a line to infinity, and see what is first intersected. The raycast algorithm they use should be dead quick, even when casting to infinity, if you''re spatial subdivision is done properly. Besides, you only have to do it once per frame, while for a bullet, you could keep the bullet in the world over several frames.

Also, it''s good to bound your model skeletons in a bounding box hierarchy, and even do a ray-triangle test, for ultimate accuracy.

Share this post


Link to post
Share on other sites
Enselic    829
quote:
Original post by oliii
energy dissipated at the point of impact (weight of bullet times velocity)


The energy dissipated is actually (mass * velocity² )/2




____________________ ____ ___ __ _
Enselic's Corner - CodeSampler.com

[edited by - Enselic on May 3, 2003 9:02:18 AM]

Share this post


Link to post
Share on other sites