Active ragdoll lifting itself

Godot Version

4.2.2.stable

Question

I was making an active ragdoll controller similar to human fall flat. I used hookes law to match physical bone rotation with animated skeleton.

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 use pin joint to pin the hands to objects to pick up.

It worked pretty well, but the problem is it fly away when lifting an object that you’re on. Any idea why?

My theory is that the object is pushing the ragdoll and ragdoll is pulling the object repeatedly somehow.

I figured it out. It turns out changing the physical bones’ collision layer and mask mess it up for some reason.