A crash course in the car physics of Carmageddon: Max Damage

A crash course in the car physics of Carmageddon: Max Damage
James Batchelor

By James Batchelor

May 11th 2016 at 11:08AM

Stainless Games’ Carmageddon returns next month with a new console title that promises the most impressive vehicular destruction since the car combat series debuted almost two decades ago. James Batchelor straps in to find out how the game’s steel-shredding effects were accomplished

In 1997, UK developer Stainless Games released vehicular combat title Carmageddon.

Known for its headline-grabbing controversial content that allowed players to mow down unsuspecting pedestrians – complete with pixelated gore – the title was equally famous within development circles for being one of the earliest to introduce physics and real-time damage to 3D games.

Such features are now commonplace, but Stainless remains determined to push the boundaries of in-game destruction even further with upcoming console revival Carmageddon: Max Damage. Following the success of the crowdfunded Carmageddon: Reincarnation on PC last year, this new title challenged the team to code a completely new generation of car physics.

Patrick Buckland (pictured), programmer and co-founder of Stainless Games, reveals the studio has held true to its tradition of using in-house core technology – a practice that dates back to 1994 – and relished the “big, juicy technical challenge” of taking things forward with Max Damage.

“As the programmer who developed the original car damage system, I took on the task of both specifying and developing a state-of-the-art car damage system that would make the most of modern multi-core hardware in current platforms,” he tells Develop.

“The techniques used in the original damage system were written for a prototype in 1994, and so actually predate Carmageddon. These were obviously woefully inappropriate for a top-flight game in 2016. So right at the start of the project we took a step back to spend time specifying the ‘ideal’ car damage system.

“A lot of reference material was taken from actual car wrecks, with the target of replicating everything that happens in real-life. Looking back at that specification document, we ended up with at least 95 per cent of what was a very ambitious wishlist, all now present and functional in the game.”

Replicating real car damage meant the team had to design the vehicles as realistically as possible. Car models were built up from individual pieces in a manner similar to the construction of actual cars, and then virtually welded together like a monocoque. 

“By mimicking this basic structure, we could better simulate what happens when the car was subject to impact,” Buckland explains.

 

BUILD IT UP, BREAK IT DOWN

Cloth simulation and physics-based destruction has come a long way since 1997 so, to begin with, Buckland researched off-the-shelf tools and solutions that might benefit Max Damage. In the end, the programmer decided the panel damage algorithm needed to be written from scratch.

“None of the other tools met our standards, so we engineered a bespoke one, which really simulates the buckling of metal – but does so fast enough to work on a console when six cars are being smashed up all at once,” he says.

“During the crashes, as well as general panel damage and pieces coming off, our system had to be able to cope with massive impacts to a car. For example, a car might be sandwiched between another vehicle and the environment, where the desired result would be total car concertinaing, twisting, buckling or even splitting.”

Concertinaing is when a car is squashed-up in a single axis – for example, if it is rammed against a wall. Buckling, meanwhile, occurs when the car is ‘wrapped’ around an axis – such as when it hits a lamppost or is ‘T-boned’ by another car. If the car has sufficient momentum, parts of it carry on moving after the collision, causing it to wrap around the object that it hit.

We engineered a bespoke tool, which simulates the buckling of metal, that even works on console when six cars are being smashed up at once.

Twisting is rarer and somewhat trickier to implement. When one part of a vehicle can’t move because it’s trapped against something solid, forces are then applied to points a distance from the trapped part so that it will twist independently. 

It’s also possible for the vehicle’s inertia to cause twisting if the impact is heavy enough. For example, if a car is halfway through a slow barrel roll and something smashes into its front corner from underneath, the front of the car may twist relative to the rear. It’s a difficult effect to mimic, but Buckland and his team found a solution.

“Our code will allow any axis to twist, just in case the forces dictate it,” he explains. “Twisting is also used when the cars are damaged by mines and other explosions, as it adds an additional ‘totally messed-up’ look to the car afterwards.

“The twisting itself had to be fed into the crushing code, so it is in fact just a layer on top, and things like the maintenance of surface area – otherwise tearing of welds or panels – must be adhered to. 

“These four instances only occur under exceptional circumstances, not just because they require enormous forces to happen anyway, but also because this type of damage can result in a car being undriveable. Conversely though, a slight amount of total twisting or buckling will really help with visual damage transmission through the vehicle on heavy impacts.”  

BENDING THE RULES

The effects of twisting, buckling and concertinaing are impressive, but they depend on vehicles being in the right situation and under the right pressure. This required a thorough understanding of the physics behind vehicle collisions.

“The physics has to make sense,” he says. “It was really important to us that these instances would be real ‘wow’ moments for the player.

"We also tried to continue the original specification of Carmageddon, which was that by strictly adhering to the laws of physics at all times, we lock into the player’s subconscious, which in turn lets them ‘feel’ the impacts at an almost primeval level.

“For the sake of gameplay, we still allow the car to be driven in a state that would be impossible in real life.

Stretching the laws of physics is Max Damage’s splitting feature – where vehicles can be ripped in half, yet continue to race around the track.

“When cars split, we divide the model across an arbitrary plane,” Buckland explains. “Anything that crosses this plane that can smash or detach must then do so. All crushable parts are then divided in two across the plane such that a vertex shader turns off vertices that would reside on the ‘wrong’ side.

“This entire process is then applied in reverse to a usually hidden split-half of the car, as well as copying over any existing damage before the split occurred. The split-half is then enabled and acts just like a normal car. The code will pick the most sensible half to remain as the main car, in case it might still be driveable.”

IF IT AIN’T BROKE

Not content with tearing its virtual cars to pieces, Stainless also went to great lengths to put them back together – while players are still driving them.

“Repairing your damage has always been a key part of Carmageddon, because it’s essential that you’re encouraged to smash your car up,” says Buckland. “Crumpling is repaired frame-by-frame in order to make it look progressive. Broken off parts come flying back to your car as physics objects, and can even kill pedestrians on their way. First, we prioritise essential parts such as wheels and your engine, which fly back to you on the very first tap of repair.

“Repairing splitting is really complex, because either or both halves may have received subsequent damage and no longer fit together. The code handles this by pulling the secondary half back to you and then morphing the join together.”

By adhering to the laws of physics, we lock into the player’s subconscious and let them ‘feel’ the impacts at an almost primeval level.

Stainless Games and Sold Out are bringing Carmageddon: Max Damage to PS4 and Xbox One on June 3rd. For Buckland, it represents not the end of this coding challenge – but another milestone in the journey he started back in the mid-‘90s.

“The work on Carmageddon’s damage systems over the course of the series’ near 20-year existence has been to keep the game at the forefront of this particular field of games tech, and I’m proud of it – as I am of the equally vital work everyone else on the team has done to bring it back,” he says.

“I look forward to continuing to work on improving and evolving the systems in years to come, as we continue beyond Max Damage and move on to the next chapter in the brand’s development.”

Article originally published in the May 2016 issue of Develop.