Cutting Skeletal Meshes at runtime

My problem:

I have an animated character (SkeletalMeshComponent). I want to be able to slice it in half and have both parts fall as separate ragdolls. I don’t want the slicing to be pre-made in the mesh. It has to be procedural (yes, like Metal Gear Rising)


My vague solution:

I want to more or less follow this plan:

  1. Prior to cutting, save all bones, vertex, skinning, material, ragdoll colliders info
  2. Procedurally generate two new meshes that represent the two halves of the original mesh (based on the saved vertex positions and material)
  3. Generate two new separate rigs that represent the bones that were originally assigned to the two new mesh parts before they were cut
  4. Re-apply skinning information
  5. Regenerate ragdoll colliders
  6. Apply ragdoll

My Questions:

  • Can procedural meshes be skinned and animated?
  • How are bones represented in UE4? I’ve seen methods for retrieving bone names and indexes in SkeletalMeshComponent, but how do I access a bone’s information, like the associated vertex skinning data?
  • How can I manually create a new bone at runtime and set its skinning info? Or is skinning info assigned to vertices?

What you’re asking isn’t really achievable (creating rigs at runtime). Even if it was, the cost of generating such information at runtime would be massive and would require heavy amounts of mulithreading to stand a chance of working.

I would recommend you instead experiment with ‘procedural mesh components’. It is possible to create a procedural mesh from a skeletal mesh, and (with a little work) you can actually specify which parts you would like to copy. So in theory you could generate an arm or a leg mesh, or even a torso. Then you would simply hide associated bones on the mesh you spawned it from and voila.

The main limitation of this method is that the resulting actor is not going to ‘flop’ around , but you could actually fake this using world position offset effects in the shader.

I have implemented this method for my own game and am quite pleased with the results :

The information here should be enough to get you started.