I was making an active ragdoll controller in Godot similar to human fall flat. I have a ragdoll which is made from physical bones (rigidbodies) connecting to each other using joints. I used hookes law to match the ragdoll’s physical bone rotation with animated bone.
I use pin joint to pin the hands to objects (Rigidbody) to it pick up.
It worked pretty well, but the problem is, lifting an object that you’re standing on makes it float into the air. Any idea why?
Here is the video showing it in action
Here is part of the codes:
func hookes_law(displacement: Vector3, current_velocity: Vector3, stiffness: float, damping: float) -> Vector3:
return (stiffness * displacement) - (damping * current_velocity)
for b:PhysicalBone3D in physics_bones:
var target_transform: Transform3D = animated_skel.global_transform * animated_skel.get_bone_global_pose(b.get_bone_id())
var current_transform: Transform3D = global_transform * physical_skel.get_bone_global_pose(b.get_bone_id())
var rotation_difference: Basis = (target_transform.basis * current_transform.basis.inverse())
var torque = hookes_law(rotation_difference.get_euler(), b.angular_velocity, angular_spring_stiffness, angular_spring_damping)
torque = torque.limit_length(max_angular_force)
b.angular_velocity += torque * delta
I was expecting the object to just flip over or not moving at all.
My theory is that the object is pushing the ragdoll and ragdoll is pulling the object repeatedly somehow.
Lower the hookes law stiffness kind of helped a bit but that also made the ragdoll very weak.