Enter the maze

Faking mayhem

gamers on a sofa, leaning over as they press their controllers

Ever spotted a glass that’s just on the brink of tipping over? In that long moment when you realise what’s about to happen your brain is performing loads of physics calculations instinctively. You’re figuring out that the glass is going to tip, how much time it will take, whether you can manage to catch it and where all the stuff inside it is going to go if you can’t.

Humans are phenomenal natural physics calculators. For computers it’s a lot harder. Really complex physics can grind a computer to a halt, which means that the designers of computer games have to strike a balance between realism and, well, faking it for efficiency’s sake.

It’s complicated

How hard could it be to put Newton’s laws into a game? Well, think about all the calculations a computer needs to make just to blow up a truck with realistic physics. The explosion itself is just the start. It needs to figure out how the smoke drifts around and how much of your view it blocks. Then there’s all the flying debris – where does it go and what does it hit? And how does the stuff in those collisions get knocked around in turn?

When you consider that most games have to crunch all those numbers for 60 frames a second, it’s no wonder that game designers resort to some tricks to get around calculating everything precisely as it would be in the real world.

The simpler explosion

One thing that all the fire, smoke and debris in an explosion have in common is that a game designer can simulate them all as clouds of floating particles. This is actually a fairly old trick – it was discovered in the eighties by one of the special effects designers on Star Trek II: The Wrath of Khan. Whether it’s a puff of smoke or a bit of a truck tyre, to make it fly through the air you just need to give it an initial position, a speed and direction, and an amount of time until it disappears.

The physics software takes things from there, figuring out where each particle goes and what it collides with in the game environment. It’s not perfect physics – simple particle systems don’t always take into account gravity or friction, or calculate whether the particles collide with each other. Designers are after a simulation that’s good enough to fool us.

a ragdoll graphics figure falls down some stairs

Playing with dolls

Another trick that game designers use is what’s called ‘ragdoll physics’. It’s used to simulate people falling over – like when baddies die in a game. It treats a body as a collection of bones attached with simple hinges. When the body falls over, the computer simulates the effect of gravity, and how the bones and hinges would move with respect to one another.

Again, it’s not perfect. Our skeletons are more complex than just bones and hinges, but the effect is close enough. Since real physics takes so much processing power to calculate, it’s better to do what looks realistic and let the computer pay more attention to what’s going on in the rest of the game.

As our technology gets more advanced though, and computers pack more processing power, it’s becoming possible to put more real physics into our games. Physics is always going to be expensive to calculate, though, so you can bet that if it doesn’t make a difference to how the game feels, designers will always try and get away with using a simpler version of reality.

This article was originally written by cs4fn for physics.org. To find out more about the world of physics, visit their website.

Ragdoll physics image by John Nagle.