Game Development Reference
In-Depth Information
Bullets and Sensors
You know Box2D is able to manage collisions between bodies and solve them at
every step. Anyway, during the making of the siege machine in the Angry Birds
prototype, something went wrong; as you probably must have noticed sometimes
the projectile passes through the castle, ignoring the collision. What happened?
Normally Flash games run between 30 and 60 frames per second, and if we
synchronize world step with frame rate, every step represents from 1/30 to 1/60
seconds. A simulation that relies on time steps is called discrete simulation , and
it differs from the real world where events happen continuously, making it a
continuous simulation .
Being a discrete simulation, we don't know what happens in the time between the
n th and the (n+1) th step, and if a body moves really fast, it can pass through another
body in less than a time step, and you'll find it on the other side of the body with
no collision. This effect is called tunneling and we obviously want to prevent it
from happening.
In this chapter you'll learn two different ways to manage contact among bodies:
• Setting bodies as bullets
• Setting bodies as sensors
By the end of the chapter, you won't have any problem managing bodies moving
at high speed.
Search WWH ::




Custom Search