Who wants to play videogames? We are making one, come see here.

Chopping up rag dolls in Unity

Since we have bladed attacks in Tomb of Rooms, I've been wanting to implement bodies getting chopped up for a while.

I couldn't find any concrete information online explaining how to do it but I decided to attempt it anyway. Since things turned out rather well I thought I'd share my experiences with the process in case anyone else is looking to do the same thing.

There is an asset you can buy on the Unity store for this. We are a very small team on a super low budget though, and we don't need a big expensive solution. We need something super simple with minimal setup as adding creatures is a long process already. Also as it turns out implementing it isn’t that taxing and can be quite fun, I encourage you to try!

My initial plan was to keep it simple, altering GameObjects, Meshes and other data as little as possible to achieve the effect I wanted.

With that in mind this was my plan:
  1. Copy the entire rag doll object
  2. Determine which polygons are on which side of the cut
  3. Manipulate the triangle data for both to divide up the polygons
  4. Cap the severed ends
  5. Remove components attached to the now empty parts of the bodies

You can find my c# source code here if you want to try it out in the Unity editor. If you are interested in finding out a bit more of the theory behind it though keep reading and I'll go into more detail.