Note: This post was originally posted on 12th January 2016
As the new year charges on Trigghy (RIOT- Civil Unrest’s coder) wanted to update you on the biggest challenge he’s had to deal with. Let’s see what he has to say.
Unity3D’S crowd physics vs Trigghy’s crowd physics
One of the biggest problems and challenges we faced with RIOT – Civil Unrest was handling the crowd. Some of the game’s scenarios only feature a hundred or so people on screen while others feature a cast of thousands! What’s more that doesn’t take into account any useable objects, scenario elements or the like… it all adds up to one heck of a lot of physics to manage as each individual needs to react to the others in its immediate vicinity. The result should look like a single mass moving and modifying itself as though it was a unique body. It really does use a lot of physics and processor power and when I say a lot, I mean A LOT!
However, when I joined the project and got a grip on how the original code worked it became apparent that it wasn’t going to work for with large crowds. Using Unity3D does have a lot of positive benefits but the code was throwing up way too many conflicts between the navmeshes and physics. Looking back I probably should have reached my conclusion sooner; characters moved in strange ways and blocked the path of others. The way the original code worked was just a mess with no fluidity to the crowd’s movement. There really was only one thing to do, drag and drop it into the recycling bin and start again.
So that’s what we decided to do, scrap the original Unity crowd physics and start over. Of course, it had been a valuable lesson I guess, leaning what didn’t and wouldn’t work. Starting from scratch on my own code I adopted a different approach. I took every character in the crowd and developed a system with which each individual applies a varying amount of positive or negative pressure on the crowd members directly next to them. The end result is a far more fluid mass of individuals that react as a crowd would in a real world situation.
Take a look at these short videos and notice in the example of the old physics how when pushed back by the advancing police line the crowd has a very chaotic, digital feel to it. Compare that to the far more fluid way in which the crown responds in the example of the new physics. You’ll also see the difference in the crown sizes too.
For the record, following a couple of days off during the holidays, we’re all back working hard on the project and are confident we are making great progress. More updates and news soon.