Help with a (soon-to-be) self balancing ragdoll

Hi all,

As the title suggests, I have a ragdoll which I’ve been trying to make balance on its own. ragdoll.blend (2.7 MB)

So far, I’ve made a script which (sort of) sits him up using applyForce. But if I attempt to push his legs to where they need to go to stand him up (from a sitting position), the push doesn’t supply any upward leverage to the rest of his body. In other words, he just sits there while the ends of his legs are pushed down.

Another idea I’ve had is to change the min/maximum angles in the Rigid Body Joint constraints, thus bending his legs directly. But I’ve no idea how to change constraint values with Python…

I’d appreciate any help. Thanks!

Wrectified_Walking_Ragdoll_Start.blend (1.8 MB)

you need something like this,but the current pose is fetal position -> spring to standing

you need something that figures out down relative to the agent facing and chooses a pose that will line them up for a stand up animation.

this applies Torque using setAngV and likely need rethought out as I was still learning physics when I wrote it.

Wow, thanks! I don’t understand some of what’s happening, though. Is the guy strictly following the armature’s animation, or does his physics “try” to follow the armature, by bending his appendages based on their position relative to the corresponding bones?

Also, is there a difference between torque and angular velocity? Or do they do the same thing?

I came across one of your other scripts on the forum (which is super helpful, by the way) that uses torque to align the player to a globally defined “upright” - which is exactly what I needed :slight_smile:

import bge
cont = bge.logic.getCurrentController()
from mathutils import Vector
own = cont.owner
axisZ = own.worldOrientation.col[2]
quat = axisZ.rotation_difference(Vector((0,0,1)))
vec = Vector(quat.to_euler())
torque = own['Force']*1

Using this, I was able to make my character’s entire top half sit up (without the “external” forces), which is awesome! The legs behave a little finicky, though. Any way to reverse the direction they’re rotating towards?

Current blend file:ragdoll.blend (2.7 MB)