Disable physical bone simulation but keep the ragdoll pose

Godot Version

4.2.1

Question

Hello! :godot:

Basically I’d like to achieve what many games do: an NPC dies, it goes ragdoll, but after a few seconds once the body settled on the ground it “freezes” in position, not ragdoll anymore, to avoid the performance hit of many bodies on the ground doing ragdoll simulation for no reason.

But if I call physical_bones_stop_simulation ( ) the NPC will pop back to it’s pre-ragdoll standing pose, no matter what, even if I disable the animation tree + player.

I hope I’m overlooking something obvious… Does anyone know a way to do this?

I tried playing around with a ragdoll to see if I could fix your problem.
Based on seeing the same thing with physical_bones_stop_simulation(), I tried to freeze the skeleton by applying the physical pose to the skeleton before stopping the simulation.

However, it doesn’t look like there’s a simple way to apply the physical pose to the regular pose of the skeleton. To do this manually, it looks like you need to perform some sort of recursive transformation operation in order to respect the differences between the two sets of bones (physical bones do not, by default, have the same hierarchy as the actual skeleton). There is no set_bone_global_pose(), so you need to spend some time implementing this.

That said, each PhysicalBone3D has a can_sleep setting that should avoid any drops in performance. Unless this setting does nothing, you should be fine with that.

1 Like

Yeah I was thinking about manually setting the bones positions somehow, what might be a problem is that not every bone has an equivalent physical bone (I removed some that wasn’t needed) so I’m not sure if it would work, I’ll have to test.
But I’ll look into can_sleep first. Thanks! :slight_smile:

edit: well, can_sleep seem to do the job, tested it with making a bunch of NPCs go ragdoll at the same time, after they stopped moving the frame rate seem to recover exactly where it was.

Still, if anyone knows a secret easy way of applying the ragdoll pose to the skeleton somehow I’m still interested.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.