How to create controlable ragdolls in UPBGE?

Hey guys, I need to ask how can we create CONTROLABLE ragdolls in UPBGE 2.5? I know how to make basic ragdolls which are ALWAYS in their ragdoll state, but I need ragdolls which become ragdolls after my command, like after getiing hit by a bullet, car, etc…
Is there a way to acheive this in UPBGE 2.5?

If you’re animating the character initially, have a duplicate of the ragdoll parented to an animated armature. When the time comes, add in the ragdoll, and match the positions/orientations of all the ragdoll parts to the ones on the armature.

Unfortunately, UPBGE 2.5 does not preserve Rigid Body Joints when adding objects… which means you’ll have to have to have the ragdoll already present in a visible layer.

Here’s an example blend anyways:
ControllableRag.blend (1.2 MB)

Another option is to use the applyTorque() function to align each of the ragdoll parts. It provides some good physics-based movement, if a bit wobbly:
TorqueRag.blend (1.2 MB)

Hope this helps!


Upbge supports adding ragdoll group instance objects


But Groups were deprecated, weren’t they? Ever since the first EEVEE-compatible build they seem to have been replaced by the Collection system.

a collection instance functions very similar to a group instance :smiley:

also note the checkbox in upbge 0.3.0 in collections ‘spawn instances’

it’s pretty much the exact same behavior except you can choose to add a ‘proxy’ now with all instances joined as a single mesh

added = own.scene.addObject('Ragdoll_Collection_object',own,0)
for obj in added.groupMembers:
    if 'boneTag' in obj:
         boneName = obj['boneTag']
         obj.worldOrientaiton = armature.worldTransform @ armature.pose.bones[boneName].matrix
         obj.worldPosition = armature.worldTransform @ armature.pose.bones[boneName].location