Help with Active Ragdolls

Godot Version

4.3 stable

Question

Hi and hello everyone!
I am trying to make a self balancing active ragdoll (for the sake of learning… might make a game with it after idk) and one crucial step is to calculate the center of mass or COM so that I can trigger the steps.

I currently have these problems :

  • bone.position returns global_position for some reason
  • The ragdoll doesnt affect the position of the whole thing ex: if my ragdoll spawns at 5,5,5 and falls at 0,0,0 the position of the player is still 5,5,5
  • I tried to slap IK on my ragdoll but that obviously didnt work… but I do need some form of IK to do the foot placement

Oh and if anyone is knowledgeable when it comes to self balancing please share as I am somewhat lost and there is not a lot of info on YT. I want to recreate something very similar to Exanima and Half Sword but I dont know the inner workings of their character controller so I am just guessing how they work.

func calculateCom():
	com = Vector3.ZERO
	for bone : PhysicalBone3D in skeleton.get_children():
		com += bone.position * bone.mass
	com = com / total_mass

Thanks to anyone that spends time to help me out it means a lot!