One of the most immersive aspects of games is in having the world respond to your interactions with it. Moving a character with your keyboard or controller is expected, you’re directly influencing the action. But having that character bump into a table and knocking the lamp off onto the floor causing it to break and attract the guards attention in the next room is a secondary or even tertiary response to your direct input. This gives the world a greater sense of being alive and responsive.
Arguably the most entertaining of these secondary reactions is when things get destroyed. Explosions, collapsing bridges, and car crashes are all very exciting to watch within a game. Partially because these things can’t be experienced in real life without a large budget and many safety precautions but also in that there is an amount of variance to each act of destruction that we can’t predict and want to watch over and over again in slow motion.
In order to accomplish this in games, physics engines are commonly used. There are many physics engines available but one of the more popular physics engines for 2D games is Box2D. Box2D has ports in many programming languages and is used in many hobby and commercial titles today.
While Box2D is an excellent engine, it supports only a basic form of destruction. In the example below, we’ve simply stacked three boxes on top of each other and allow you to fire a projectile into the stack causing them to topple.
It’s mildly entertaining and with more boxes it could get a bit exciting but it’s still quite simplified. The boxes themselves suffer no damage as a result of being hit with the projectile and can withstand being hit by the projectile multiple times.
Wouldn’t it be cool if the boxes responded more realistically to being hit with the projectile? Wouldn’t it be more immersive?
These questions are what we’d like to explore in this series of posts on Destructible Physics Environments. We’ll start out simply and try to see how far we can push dynamically destroying objects in a physics environment to add to the immersion of a game environment.