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!

2 Likes

Upbge supports adding ragdoll group instance objects

2 Likes

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

https://docs.blender.org/api/current/bpy.types.PoseBone.html#bpy.types.PoseBone

Pls guys how do I get this EEVEE compatible build

1 Like

It looks like the same way, it’s just the group-adding that’s changed (if you want to add the ragdoll from another layer).

As BPR mentioned, you can add a Collection instance with SHIFT-A, however I’ve noticed the physics can be a bit weird:

It seems that collection instances don’t get their own physics sims, and just copy whatever the original group instance is doing. If the original is hidden, the instances spawned are completely static.

Not sure why it does this, or if I’m doing something wrong…

Alternatively, you could just spawn everything individually; but since that wouldn’t respect pre-existing constraints, you’d have to add the rigid body joints in-game.

There is a option per collection, a little check box to spawn instances in the object property tab I believe

hmm - it appears broken in my version atm - (this object must be on a inactive layer?)

even though hidden.