Enemy ragdoll-effect after death

Godot Version

v4.5.1

Question

Hi!

I’m working on a 2D-game where I want my enemies to become “ragdolls” after death, but I can’t seem to make them stay “ragdoll”.

My current plan was to replace enemy CharacterBody2D with a RigidBody2D after death. This works, but the RigidBody2D is only “ragdoll” for maybe the first ~.5 seconds after introduced to the level, and afterwards it becomes as solid as the ground underneath it. While I expected that I should be able to push the corpse around with my player?

This is my “corpse” tree structure (it is just 1 simple CapsuleShape):
EnemyCorpse (RigidBody2D)
├── AnimatedSprite2D
│── AnimationPlayer
└── CollisionShape2D

  • The corpse Collision Layer/Mask corresponds with what the player can detect and interact with.
  • I have turned off all optional “Deactivation” on my RigidBody (Sleeping, Can Sleep, Lock Rotation, Freeze)
  • I have tweaked and lowered various physics-settings, but since the corpse detects collision with the player just the first moment, I suspect it is something else I am missing.

Can you help?
Let me know if you need more information, like code etc!

Could you delete the skeleton or parts of the skeleton to make them rag doll?

Hello Brutal!
I’m not sure I follow. I could try to expain better; this is just one, simple shape, with currently no joints attached to it. I just want the player to be able to push the corpse around, and also prevent that it gets in the way (without removing it).
I also forgot to mention that the corpse only detects player interraction for about ~.5 seconds, so I suspect I’m doing something very basic wrong in some settings somewhere.

Okay, the ragdoll-effect now works!
I think I had some timing issues, I was trying to call a lot of physics to the “corpse” while it was being loaded into the level. Using “call_deferred” seems to have solved the issue, probably by waiting until other processes were complete.
(So instead of apply_torque_impulse(..)call_deferred(“apply_torque_impulse”,…))

2 Likes

Sorry for my confusing answer I must not have understood the question.

I’ll have to give this a shot in my project too! Thanks for posting the solution!

1 Like