Showing posts from October, 2010

Tunneling explained

Tunneling is an effect where two shapes can get stuck in each other or simply pass each other without impact. The effect exist because we are limited by the CPU and have to do the calculations in timesteps instead of one continuous stream.The effect comes apparent especially at high velocities and/or with small shapes. Bullets of a gun is a perfect example because they are usually fired with high velocity and are small in size. To illustrate this, have a look at the following picture:
(The numbers illustrate the timestep/seconds)Imagine that it runs at 1 second per update with a velocity of 34 pixels/second
Everything is fine because the bullet hits the wall as it should and the physics simulator responds with a proper collision reaction.But when we turn up the velocity to 89 pixels/second, then this happensThe bullet went right through the wall - the physics engine never had a chance of responding to the collision because it never happened - that is what is called tunneling.What ca…