If you ever played Max Payne 2, you probably remember your first kill. A dude rushes through a door and you swan dive before filling him with lead in slow-motion, the physically simulated bullets thudding against a body that reacts to every shot.
The goon flies back, hits a shelf, and sends it toppling along with its contents which spill in every direction. Load the game up, do it again and you’ll have a similar experience, but it will never be exactly the same. It’s not the same because it isn’t pre-canned. It’s a physics simulation.
There’s an unwritten rule in game development that you put all the money upfront. You show the player your most impressive tech advances within the first couple of hours. That’s because the majority of players never finish a game. With Max Payne 2, this is what Remedy was doing: the studio was showing off the new physics tech, teaching players this was no ordinary shooter.
In Red Dead Redemption, Rockstar achieves the same by letting you wander around Armadillo. You get off a train and walk into town. Dust swirls in the breeze, a tumbleweed rolls by, people mill about, and a drunk stumbles out of the saloon. Rather than simply walking on a predefined route, however, the drunk is powered by the behaviour coded into him – walk out of the bar and in this general direction – and a rule: you’re drunk. If you’re lucky, he might even trip over the kerb near the saloon. If he does, that’s the game’s physics model – a random element – interacting with that behaviour.
Both of these are great games, and their physics models play a big part in that. Remember the first time an NPC grabbed the boot of a car you just stole in GTA 4? These unscripted moments are far more memorable than any expensive cutscene. Of course, it can always lead to stuff like this, which is as funny as it is frustrating:
Another great game that begins by showing off its physics is Half-Life 2. You get off the train in City-17, you pick up some litter for a Combine soldier, and it’s not long before you’re in a park dicking about with swings. That small playground is a statement of intent: it’s not there for story reasons, it’s literally a playground and you are encouraged to mess with it.
It’s now 2018 and there are still video games being released where the playgrounds – whether literal or metaphorical – are static props. There are still dedicated driving games with handling models that are inferior to GTA 5, an open-world game where the cars feel like actual physical objects. There are still shooters where the only reaction background props have to gunfire is a fresh bullet hole decal.
Video games cost a fortune to make, but all the money and advancements seem to be going into making them look nicer on a surface level. Why is that? I asked Ross O’Dwyer, former head of worldwide support at Havok, now director of engineering at Oculus, to see if he had any answers.
“Getting your collision detection optimised and your constraint solver stable are two of the more challenging optimisation / mathematical problems faced in game development today,” O’Dwyer says.
Some developers build their own custom solution, but there are two main options for third-party physics engines studios can use. One is PhysX from Nvidia. PhysX is free, but it isn’t as robust a solution as the industry leader, Havok. The problem with Havok is that a license for it costs hundreds of thousands.
“There’s very little excuse for jarring physics,” explains O’Dwyer. “It’s generally a case of negligence or a lack of education, or in some cases the need to pick a sub-par physics solution due to budgetary constraints.”
To explain that a bit more, let’s go into more detail on what exactly is holding companies back and pushing up development costs. Because physics are different for characters, vehicles, and objects, I’ll break them down into sections.
How character controllers interact with the environment in games is often pared back because developers don’t want the player to be frustrated by control being taken away. If you’ve played GTA 5, character controllers interacting with the environment is the reason you can jump into a wall before slapping into it and falling into a heap. These interactions, if they are implemented at all, are often low on a developer’s priority list.
“Blending your character controller with your environment and understanding that you may need to design your level collision geometry to support the character controller model is something that many studios neglect until late in the day,” O’Dwyer says. “Then the cost to changing all of the geometry because you tend to bounce upstairs, for example, is too high, or they can’t afford the memory cost of having that extra geometry so you get strange movement of your character.”
Making the pre-set animations blend naturally also isn’t easy and needs a dedicated developer working on it, collaborating closely with the animators. Additionally, this puts the cost up and is something – at least in the eyes of the studios making games – most players won’t even notice.
There’s nothing more satisfying in games than shooting an enemy on a vantage point before watching them tumble to the ground below, hitting every object they touch on the way down. Of course, any random element you add into a game opens it up to some strange behaviour.
If you have ever seen an in-game character fly into the stratosphere because you breathed on them (like this weird bug I saw in Ghost Recon Wildlands), that’s likely because the physics coder and the animator aren’t working together as well as they could be.
“Often it comes down to just needing a good class in teaching folks how to set up a reasonable ragdoll representation for animated characters,” O’Dwyer explains. “This is a job that needs experience but often gets handed to an animator without experience. When the animator doesn’t build up a good relationship with the physics coder, you get more explodey ragdolls where the transition from an animated pose to a physically constrained model isn’t handled smoothly.”
The Unity and Unreal engine are built on top of PhysX, so these have built-in solutions for this problem, but many triple-A games don’t use these engines and instead opt for their own solutions. It’s a problem that’s been solved, but triple-A studios keep forcing themselves to solve it again.
“Graphics gets taught in colleges, but the art of the perfect ragdoll does not. It’s sad,” O’Dwyer states. “Then if you want to start blending physics with animation you get the age old control of the character representation – your animation department will say you’re killing their artistic intent if you just blend the ragdoll with their animation, and constantly running ragdolls adds a cost so devs step back. It’s a shame.
“The better models keeps the physics running in the background, builds a massive animation search tree for reactions (thereby maintaining artistic intent) and uses the deflection on the physics character to drive the animation tree up top, but it’s expensive. Until we get to super cheap mocap and massive animation trees that can be repurposed to any character in the game, the cost is just too much for studios to bear.”
If you want further reading on ragdolls, I once wrote about the development of GTA 4’s Euphoria physics over at Eurogamer.
Playing The Crew 2 was what prompted this feature. This is a racer where you are free to drive from Los Angeles to New York, but the bones of the game – the actual driving – feels off. It’s the physics. You’re constantly speeding over jumps, and you feel like you are being bumped into the air like a pinball. Get on a dirt bike and it feels even more unnatural. The Crew 2 is supposed to be an arcade racer so you can’t expect it to offer something as realistic as Codemasters’ Dirt series, but there should at least be an attempt at creating an illusion.
“This really often comes down to playablity and the difficulty curve you want for your players,” O’Dwyer explains. “You want to be able to drive at a million miles an hour and corner on a dime and feel fun. That’s not physically realistic so most vehicle models become a work of fiction. The wheels don’t touch the ground, you cast rays to understand where your wheels should be and you model everything through a tight control system where you can tweak the playability and allow a different feel for different vehicles, but have it so that when you hit a kerb at 110 miles an hour your car bumps, rather than getting launched into space as might happen with a real suspension system.”
Another potential barrier to physically simulated vehicles is the fact that the cost goes up when more vehicles are introduced. If you have a traffic system and you physically simulate those as well, your memory fills up.
“So you fake most cars but make the player’s car good, and you care more if you’re purely a driving game,” O’Dwyer explains. “I think it really comes down to what the market demands. Will the game sell better because of the vehicle model if the one they have is ‘good enough’? The Godfather car engine (from 2004) is very close to the same engine used by most games built on Havok unless they leverage more advanced models that were added to the system to support simulation needs. When that happens, though, the learning curve becomes like driving a real car and stuff gets less fun.
“At one point, I worked with a team that built a physically accurate model of a shopping cart you could jump onto and ride. It behaved in the most accurate way you could imagine, but the learning curve was crazy. The testers became amazing at the game, they could do things you couldn’t imagine, it felt real, they were like skateboarders on a mission. But hand that to a new player and they constantly died and gave up. The game never shipped.”
In 2001, Red Faction allowed players to modify levels with explosions, creating makeshift tunnels and altering the geometry with your tools. This wasn’t a physics simulation, of course – the game just replaced chunks of the level with empty space – but it hinted at a future where game worlds reacted to your gunfire in a proper, simulated way. We’ve seen some advances here, such as Rainbow Six Siege’s wall-tearing destruction system, but why isn’t it more common?
“There are a couple of issues here,” O’Dwyer says. “One is that you massively increase your content budget if you need to create destructible representations for all the objects in your games. The ratio of coding to content budget shifted over the last 15 years where content is a massive cost for any production. If you make everything destructible, you need pipelines that cut the cost of creating these versions versus multiplying the number of assets you need by three. Then you have destructible stuff. Now when you break things you have three to five times the number of draw calls. There are ways around this and DX12 and Vulkan resolve this hugely but with most render pipelines that increase in the number of objects was prohibitive.”
Even if you solve that issue, you have to solve another problem with AI. What happens when an AI’s path gets blocked, for example? Suddenly, you need procedural animations so the AI can navigate over broken terrain, upping the level processing time and filling up the animation database. You also have the added factor of the player dicking about with physical objects, breaking the flow of the game by constantly launching bricks at friendly NPCs. Developers call this ‘Asshole Physics’.
“These are hard problems and your team needs to get trained and… so teams step back and games don’t progress,” O’Dwyer explains. “All of this said, there are games that push physics hugely. DICE’s Battlefield games, built on Havok tech, solved the pipeline and really went to town with this. You see secondary physics being leveraged far more so cloth in Destiny 1 and 2 and in sports games where they will invest in rich animation trees shared among all characters and being driven by intelligent physics engines.
“It mostly comes down to investing in your pipeline and the fact that the industry centred around free PhysX versus picking up Havok and working on raising the bar on their integrations. Had that happened you’d see the bar raised and reviewers and consumers would no longer accept second best.”