What's the simplest way to make armature ragdolls in BGE?

In most of the BGE plans I have, I wanna use some form of ragdolls. The type you see in any modern game, where a person getting shot dead causes them to realistically roll down hills and collide with objects, all limbs reacting properly to the physics.

I know it’s possible in Blender Game, but the methods I seen are pretty complex and confusing. Last tutorial I remember watching required that you place a cube at the location of each joint, parent the cubes to the bones, then add an extra armature with one bone on top of each cube again. I am looking for a script-less way to achieve this also.

Note that for what I had in mind, objects are meant to be animated initially before being ragdolls. So for example there could be a person walking around (and playing the “walk” armature actions) which then gets shot and becomes a ragdoll from their last position and state of animation. If this is not possible though, I can go with making an animated version of each character as well as a ragdoll version, and switching the objects once the character dies… just that such would be less accurate and realistic.

Anyway, what’s the easiest and “shortest” way to make ragdoll armatures in BGE, and let all bones be physical? Simply attaching a box to each joint with a constraint sounds ok, but is it possible to stay as simple as that?

switching is easy with states, but that whole ragdoll is complicated. stick with the tutorial, that seems like the best method i can think of.

Search for a user named “BluePrintRandom”. His posts can be difficult to understand sometimes but he does a lot of stuff with rag-doll type animation.

Only found a few of BluePrintRandom’s posts on ragdolls… can’t say it clarifies much about armature ragdolls.

And I’ll probably look at the tutorial again. It’s not very difficult to actually achieve the ragdolls, but using so many boxes and extra armatures feels wrong and hard to work with and maintain. Bones themselves have no collision size IIRC, so you need to constrain them to other physical objects… still it probably shouldn’t require more than just that.

Hi I’ve been working on this for some time. The method I use for making a ragdoll is this:

Step 1: Make a ragdoll by creating simple objects with rigid body constraints. Give each ragdoll piece a name with a prefix+bone it will be connected to e.g. “RD-head”

Step 2: Add empties to the head of each bone in your rig. Parent these empties to their corresponding bone. (thus, each empty will follow the location and rotation of their corresponding bone) give each of these a name with a prefix+bone name e.g. “FOLLOW-head”

Step 3: At the tail end of each bone, create an empty. Parent this to the ragdoll piece that corresponds to that bone. This will act as an IK target for the bone during the character’s death. Name these empties with a prefix + bone name. e.g. “IK-head”

Step 4: At the tail end of each bone and offset from the bone’s local Z axis, create empties. Parent these to the IK empties made in step 3. These will act as pole targets for the bones during the character’s death. Name these with a prefix + bone name. e.g. “POLE-head”

Step 5: Add IK constraints to each bone, targeting the IK empties made in step 3 and pole targeting the empties made in step 4. Make the chain length 1. Set the influence of each of these constraints to 0.

Step 6: In the game logic for each ragdoll piece, make it so that at the start of the game, the pieces are parented to the empties created in step 2. Also, you’ll need to suspend dynamics. This will make it so that your ragdoll follows the armature. Make it so that whatever trigger’s your character’s death also deparents the ragdoll pieces from these empties and restores dynamics. This will make it so your ragdoll flops.

Step 7: For each bone in the armature, create an Armature actuator set to “Set Influence” mode. Make it so that whatever triggers your character’s death, also sets the influence of your IK constraints to 1. This will make it so that your armature will follow the IK & POLE targets that are parented to the ragdoll pieces. You will also need to do this for a ‘COPY_LOCATION’ constraint to the hip bone targeting the Ragdoll’s hip piece.

I’m currently working on a plugin that does all this for you, but it’s been a bit of a tricky project… Here’s an example of this method at work (I was working on making it so the character could die, then get back up.):

GOTCHAS: I’ve noticed that if your character’s animation forces a ragdoll piece to go beyond the limits set in the rigid body constraints for that ragdoll piece, then that piece is in a dangerous zone. If the character dies while that piece is in the danger zone, it will break the rigid body constraint and the ragdoll piece will go flying off. The best way to prevent this is to make some limit rotation constraints and transform locks on your character’s armature, then match these limits to the rigid body constraint’s limits. This will prevent the possibility of going beyond the rigid body constraint limits.

Still way too complex that what I was hoping for. Anyway it’s ok, I found a tutorial on Youtube and it shows the simplest way to get ragdolls in BGE… just what I wanted. Already tested and it works :slight_smile:

Basically: You have your rigged mesh which you want to make a ragdoll. At the location of each bone, create and place a cube mesh… optionally naming each cube as its bone to make things easier later on. Make all cubes invisible and ridgid bodies, and give no collision to the real object’s mesh and armature. Then connect the cubes with each other using Ridgid Body Joint constraints. Lastly, select the bones on the armature and add a Copy Location and Copy Rotation constraint specifying each one’s specific cube. Oh, you must also add a Run Armature actuator in the game logics on the armature for it to really work in-game. That is it :slight_smile:

That’s simple and easy enough for me, so I will go with that. Thanks for all the replies and info.

I can help :slight_smile:

So, you make rigid bodies, that are constrained with 6dof settings, like head, torso, upper arm, lower arm etc, and set there “min and max rotations” so they can only move like a real person,

then use the Rigid bodies as IK targets for your armatures, and make sure you have “always run armature” in your armature and both the “skin” and “armature” should be set to sensor or no collision, all collisions are done by the invisible rigid bodies :slight_smile:

here is a physical walk cycle procedural animated 3rd person rig that still needs alot of love :slight_smile:

after wrectified is done it will be much more mature, but I have so many other “pieces” in play, that I just have not had the time :slight_smile:

TorqueWalk= bare 6dof rig
Runfast = generic man rig

Rig-Akira_B_Model- (quick weight paint rig, that is not done but proves the point)

next I am working on IK solvers using forces and torque and “Torque Track To”

Attachments

RunFast.blend (1.95 MB)TorqueWalkFinalk.blend (539 KB)

Here is another rig,

Attachments

Lizard (jump).blend (951 KB)

Check out the BRIK add-on, from armature to ragdoll in a few button clicks :slight_smile:
Joint limits are set based on the IK-limits of the armature

For the link see my signature

I agree that using copy rotation constraints is much smarter than using IK constraints. I’ve hit a major roadblock however. I have made my character and grouped all of the ragdoll pieces with the character’s armature and mesh, but when I try to library link this character into a level I’ve created, blender crashes. I did a small test and it seems that the rigid body joint constraints don’t play nicely with library linking. Has anyone found a way around this? What I’ve been doing is simply appending my character instead of library linking, but this is hardly ideal.

Here’s an example: Try library linking this file into another blend file and it will cause a crash when you start the game engine

Attachments

ragdoll experiment.blend (471 KB)

If anyone is still interested, I created a script that will automatically generate a ragdoll for your character as long as your character is using a rigify rig. Here’s what the script does:

  1. Adds some rigid bodies (with a human shape) to the rig’s org-bones at their location rotation and scale.
  2. Adds rigid body joint constraints with some default values (you can adjust these to make them perfect.)
  3. Adds Copy rotation constraints to the bones targeting the ragdoll pieces and sets the influence to 0
  4. Adds a copy location constraint to the ORG-hips bone targeting the ragdoll hips
  5. Adds null objects at the head of each bone and parents these to their corresponding bone.

How to use it:
Use alt+R and alt+G to put the character’s rig bones into their default positions.
Go to object mode, select the rig, run the script. (You may need to adjust the size and shape of the ragdoll pieces)

In the game logic, make it so that at the start of the game, the ragdoll pieces are parented to their corresponding empty and use suspendDynamics() to make it so that the ragdoll piece doesn’t fall to the ground

Make it so that whatever kills your character also removes the ragdoll piece’s parent and restore’s dynamics.

In the game logic, make it so that whatever kills your character also sets the influence of all those copy rotation constraints and that one copy location constraint to 1

You’ll also need to change the collision group of your ragdoll pieces so that they don’t interact with the object you’re using to control player movement.

Here are the scripts and an example:

https://docs.google.com/file/d/0ByCbzbfsSzJLcS1FR1V4eU8tSEE/edit?usp=sharing

My rigs use ragdoll to run and move, using 6dof RBJ’s + torque or forces to animate not actions :slight_smile:

this is where the rub lies, they really have to be able to walk… like a real person, however this is not as CPU intensive as 1 might think, since I can mix an infinite amount of animation states :slight_smile: and there are 0 Keyframes

I need your scripting skills applied to what I have done in almost all logic :slight_smile:

I don’t have any scripting skills for Blender and Python in general sadly. Anyway that sounds really interesting and awesome! Can you post a .blend file of a character that walks that way in BGE, if you’re ok with sharing any such examples?

There posted above :slight_smile:

check out Torque Walk and then look at this

this has a model akira made bound to it, it still needs re-topo and better weight painting,

<-Torquewalk

This script generates your ragdoll from your armature. Then makes it easy to toggle the ragdoll on and off. He’s still polishing it up, but it works pretty well now.

Ragdoll Generator by Liebranca

1 Like

hi there you can help me? i create my skinned ragdoll for dead action spawn but mesh is deformed if spawned in diferent Z axis of default.
please look my topic here.

i think need set influence or use the rotation box objects of ragdoll?

Here are all of the scripts I wrote for making ragdolls. Please note that I haven’t touched the game engine for several years and when I was playing with it I was brand new to python (and blender). These scripts worked with the rigify metarig at the time and will likely all fail now that rigify has been updated and the Blender API has changed. You’re welcome to look at the code and glean what you can, but I don’t plan to make any updates for them.

Ragdoll.zip (18.4 KB)

thank you my problem is with just deformation mesh when dead ragdoll spawned in different Z axis angle from default angle where is ragdoll in inactive layer understand? my default is Z axis is 0.0. if spawned in 0.0 or 180.00 degree no deformations.different angles ocurr deformations.Spawn point work like track to player understand?
may be need update bones rotation or dead ragdoll or objects box rigid body dont know :confused: