Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've done some research into different collision detection methods but I don't know when I should be using one over the others. Some I've seen are:

  • Continuous Collision Detection (CCD) or Raycasting
  • Quadtrees
  • Discrete stepping

So for example if I want to shoot a bullet which method would I use? Well I've herd CCD is the way to go for that. But what if I have an unrealistic machine gun that has a huge rate of fire making 100 bullets shot at any given time. I don't know if I should be using a quadtree or be consistent and use CCD or even use something else.

Could I get some clarification on what each method is best suited for? That way I'm confident I'm using the right method for the situation. Also if you know of any other good collision detection methods let me know. Oh and if the dimensions matter I'm talking 2D here.


share|improve this question
-1 Not a great question spawned from a misunderstanding of these methods (or lack of research), especially leading to an assumption they're comparable. This would be better split into three questions asking when to use quad trees, when to use discrete steps, and when to use CCD. If discrete stepping and CCD are opposed (i.e. you use either-or) - I'm not sure if they are at the moment - then those two questions could just be combined into "When should I use CCD vs Discrete stepping?" Voting to close as not a real question. – doppelgreener Aug 15 '12 at 7:56
up vote 3 down vote accepted

Quad trees are a totally different thing than the collision method. Quad trees are a form of spatial partitioning. Spatial partitioning helps weed out distant objects when trying to find pairs of colliding objects or testing ray collisions. Spatial partitioning is technically entirely optional, but in practice is required for performance.

Continuous vs discrete determines how often collisions are checked for. Continuous collision detection works without stepping time, instead checking to see when the next collision would occur and telling you what time that collision will be. Some folks also call swept volumes a form of continuous collision detection.

The primary advantage of continuous collision testing is to avoid tunneling. Tunneling occurs in discrete systems because objects are only checked for collision at specific intervals. If an object is small and fast enough, it may be completely on one side of a wall at one time and the next increment it will be completely on the other side. Continuous collision detection also provides more accurate results, as it can tell you the precise moment two objects will collide, while discrete systems only find out about collisions after the objects have penetrated each other.

The primary advantage of discrete detection is that it tends to be much faster and simpler for objects with complex shape or large size. Continuous collision detection requires mathematical descriptions of all objects and their motions and the solving systems of equations, which can be difficult, slow, or outright impossible in many circumstances.

Swept volumes are a way of using discrete detection while solving tunneling. You can take an objects current position and old position and enclose a shape around both of them ( this would be a line if your objects are points, a capsule if your objects are spheres, etc ). It is not as accurate as continuous collision, but simpler.

In general for simpler physics engines, use discrete methods for most objects and use a ray cast (continuous) for bullets. Specific games might need to use continuous or swept volumes more often, depends entirely on the specific game.

For things like your machine gun, consider simply reducing the number of bullets. Players really aren't going to notice 100 individual bullets when you can "cheat" and simply draw a bullet spray wffect and use a much smaller number of rays for actual hit tests.

share|improve this answer

A lot of shooters tend to use limited range on their bullets making line collision detections instead of using rays. This is quite a bit faster than raycasting because it has an extent. You could also do updated line collision, making smaller lines that move over a few frames to do accurate collisions so you don't get shot and killed as soon as someone pulls the trigger, this being most noticeable on long range weapons such as a sniper.

You can also use a combination of both line collisions and a tree, allowing you to only grab the areas that you know the bullet will be within and check with in those.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.