Theoretical Bullet Termination Method


(ST150) #1

As we all know there are reliability issues of using collision detection of high speed objects for bullets. Rays can be used as an alternative, but you won’t have those flashy bullet effects. So I’ve thought of a method which merges a bit of each.

An object casts a ray to represent the bullets path, then adds a high speed bullet object. Using a distance formula and the getHitPosition() of the ray, calculate the distance to whatever object the ray hit. Now you already have the speed at which the added bullet will be travelling. With this information you can calculate the exact length of time the bullet needs to exist to travel to the hit point and terminate itself. Using the simple formula:

Time = Distance / Speed

This should result in perfect termination of the high speed objects when they collide with an object, even though the effect doesn’t use collision detection. A complication with the method is time of an added object is measured in frames instead of seconds. With the new fixed timing rates this shouldn’t cause too much of a problem to convert though.

Has anyone tried this method before? Would the added logic processing outweigh the reduced physics use for overall performance?


(Pseudonym) #2

that is good for shooting a wall, but what about a moving object? maby you should find out how many blender units the bullet moves each frame, and have a ray sensor on the bullet that long, and terminate the bullet when the sensor is triggered?


(ST150) #3

Yes this technique does assume the object will be stationary or moving at a very slow speed relative to the bullet. In practice unless the object is moving at very high speeds it doesn’t matter, as the bullets themselves are almost instantaneous.

The idea behind this method was to have a single ray per source and avoid having a sensor on each and every bullet. In big fire fights this can lead to quite a big performance drop.