# How do you detect collisions with fast objects like bullets?

I am currently trying to make a tank to work in the game engine. I have the body roughly done and am trying to get the gun to work. Just making the barrel create a shell at a high velocity doesn't work because the shell travels to fast for the engine to detect a collision. If I have the velocity down enough that the collision is detected, the shell doesn't really have enough speed.

Are there any other ways to make a shell behave like a bullet and still detect collisions? I've tried making the bullet larger, but that still doesn't always collide.

In the physics tab turn up the Physics Steps > Substeps. This will calculate physics in between frames.

• Am I missing something really obvious? I can't find the Physics Steps option. I saw it just the the other day... i.stack.imgur.com/Cb5eG.png – American Luke May 25 '13 at 1:04
• Never mind that, I found it. Just looking the wrong place. This works, thanks. – American Luke May 25 '13 at 1:22
• Shouldn't that slow down the calculation time significantly? I don't know how physics intensive the OP's game is, but that might cause it to lag. – Gwen May 25 '13 at 1:33
• @Gwenn turing it up to 4 might, but having it at 1 or 2 should not effect performance greatly. – CharlesL May 25 '13 at 11:36
• @Gwenn Right now the game is really rough. The models are kinda boxy and the colors are just slapped on. I don't know how it'll function in the final version, but right now it's doing pretty good even when I turn it up to 4. – American Luke May 25 '13 at 14:45

Another option is to use a raycast sensor in front of the bullet object is probably the most performant and reliable solution. The ray length should be longer than the distance the bullet travels per physics frame (which should be 60hz, assuming you are not using physics substep).

The problem is that your bullet shell is traveling so fast that it goes clear through the target object between frames.

One option use can use to solve this is to simultaneously create your bullet shell and an empty shell that is longer than the original bullet and aligned with it. The player will only see the visible bullet shell, but you can use the invisible one to calculate collisions. Even if the visible bullet passes through an object between frames, the invisible one won't, which allows you to still catch the collision.

• I've tried that, but it still doesn't always catch it. It also can make the physics of the impact look qwerky when it does catch it. – American Luke May 25 '13 at 14:43
• @Luke If you decide to go the empty-bullet route, you could solve the strange physics problems by instead using a string of overlapping individual empty bullets. CharlesL's solution sounds cleaner overall, but if you encounter lag, it might be nice to have another option like this handy. – Gwen May 27 '13 at 2:05
• Alright. I'll consider switching to this method if it starts lagging as I work on it. Thanks – American Luke May 27 '13 at 16:38

maybe try using the near sensor to activate your logic when your bullet is within a specified distance from your target? Since it is a distance parameter rather than a collision parameter, it may behave differently. I haven't tested it but it might be worth trying.