Physics with your friends!
Destruction is something that has been done before in games. A recent stand out was Teardown. Teardown takes an interesting approach in that it uses voxels for both rendering and physics and a therefore avoids expensive physics calculations. Teardown was made by a small team and I would call it indie. Moving into the AAA space, Embark has released The Finals and is holding open beta’s for it’s latest game Arc Raiders. What makes those two titles interesting is that they feature online destruction. That is to say that not only do you have to simulate destruction on the server but, it needs to be consistent across all clients. I believe I am the first indie studio to attempt online destruction like the Finals, Battlefield, or Arc Raiders. I think physics makes multiplayer games interesting! Much like Teardown, I have a few clever tricks up my sleeve and I wanted to share some of those here.
Procedural Animation
A droid using the Animation Rigging package to walk!
Of course my game: Gone 4 Good, is still a work in progress so, this is how I have it blueprinted out and things could totally change later in development. I plan to have large robots that the player can harpoon and pin down. Once harpooned, a robot or “droid” find’s itself increasingly constrained as more harpoons are attached. Having enough harpoons in the droid’s leg(s) with increasing tension as players pull, will eventually allow the droids to be pulled apart. Parts of the environment will also be destructible. Enemies, friendly npcs, and player controllers all need to account for the environment changing at runtime in a physically accurate way.
Now, onto the implementation details: I am using Unity’s animation rigging package to place foot waypoints where they need to go via scripting and then Unity handles the IK rig for the legs so that they look anatomically correct. (yes its robot anatomy… whatever!) I also have a complete ragdoll setup for this character, with each rigidbody set to isKinematic = true; at start. As each harpoon attaches to the droid’s leg, I average the positions of all of those harpoon endpoints to come up with a position for the leg’s IK hint. This gives it that twisting look while keeping the robot’s foot firmly planted in the ground. Should the hint’s distance get too far from the droid’s character model root, I turn off the animation rigging for that leg, switch the script into “single leg hop mode” (lol) and set all of the rigidbodies on that leg to isKinematic = false;. This makes the leg go limp in mid-air and because I am using the Obi Rope asset, the ropes are all rigidbody-compatible and can therefore apply tension to the leg. I simply use Unity’s “break force” parameter to calculate if a leg should fall apart.
As for the networked destruction, I plant to cherry pick easier game objects to destroy. For example, I plan to have the floor of certain upper levels of the nightclub be destructible. Because I am using Unity’s navemesh system, this means that I need to recalculate the navmesh at runtime. I plan to run dedicated servers and this kind of lets me cheat. If you think about it, the clients would notice an entire level navmesh re-calc because they are actively drawing many frames per second but, the server could see dips and so, as long as your client code can handle the spaces in network packets - everything should work out fine! This might even let some clients who are behind catch up! Of course, everything in moderation. We don’t want any lag spikes. Networked destruction is pretty straightforward- I plan to use Rayfire to break up the objects beforehand and then at runtime track their positions as things fall apart.