Running and diving with your friends is fun, but what's the point of it all if you can't put your friend’s faces in the dirt? That is why we added ragdolling. Plus, just look how goofy it looks!
Goblin ragdolling on the ground
The first question we had to ask ourselves when adding ragdolling was if we want to let players tackle anyone, or only the enemy. Making teammates immune to the ragdolling would require less team coordination in that two teammates could dive at the same enemy and not be punished for hitting each other. It would also allow teammates to stand in between an enemy and a teammate with no repercussions. For these reasons, we decided that we would allow teammates to ragdoll each other.
One issue this brings into the mix is griefing your teammates. Sometimes, people just want to watch the world burn and for that reason we had to think of anti-griefing measures. One system we put in place to stop griefing is a “grace period” between opportunities for one player to tackle another. For instance, if two players just ragdolled from each other, there is a small window after they get back up during which a tackle won’t ragdoll the other person. This allows that person a window of time to get away from the would-be griefer.
Goblin bounces right off due to the grace period
Now for a little under-the-hood look. In a multiplayer game, ragdolling can add a lot of randomness that you definitely don’t want. If the server thought you went one way and the client thought you went a different way, you have a big issue on your hands. For this reason, when adding ragdolling into a multiplayer game, remember this one tip! Have the ragdoll follow the character, not the character follow the ragdoll. This means that all of your movement calculations should be based on a deterministic object instead of a random one like a ragdolling physics body. A simple way we did this in Bugby was by using a physics constraint to essentially “weld” the player's mesh to the rest of the character. Doing so allows both the server and clients to see different ragdolling effects while keeping the players in the same location.
Physics Constraint between goblin mesh(blue box) and the player’s hit box(red box)
I hope this post has shown you a bit of the thinking that needs to go into including ragdolling into a game of your own. If ragdolling fits into your game, I recommend including it. It always brings lighthearted fun to a game and isn’t too hard to implement, even in multiplayer, if you are smart about it.