Undo ragdoll

Hello,

I want to undo “Simulating physics” from a skeletal mesh. I know I have to use setSimulatingPhysics to false… but this doesn’t work. I did 2 screenshots from the “mistake”:

This is the skeletal mesh (the zombies) , who are simulating physics. But when I set simulatingPhysics to false, the whole mesh (the zombie) turned 90 degrees like this picture:

Is there an an other way to undo this ragdoll?

Thanks. Jojii.

When you ragdoll the mesh of a moving character, it will detach from it’s capsule collision component (which isn’t affected by the ragdolling so just stays put) and flop about on the floor, changing it’s local position and rotation in the process. When you turn off simulate physics, the bones will snap back to their original positions but the new location and rotation remains, causing the character to stick through the floor.

To fix this, you need to revert your mesh’s local rotation and location back to what it should be and ensure the capsule snaps to the mesh’s root bone as it’s ragdolling (in the tick event, for example) or snap it when it’s done, otherwise the mesh will jump back to the capsule’s position. Finally, you’ll want to re-attach the mesh to the capsule so that everything moves as one again.

Here’s a similar question on the subject, with a blueprint graph showing how it was solved. In this example, it was for a player character with a button to toggle ragdolling, but the principle remains largely the same.

But as I used this code, he flew.

this is my code:

Looks like you’ve zeroed out their location and rotation relative to the capsule rather than set it back to what it was prior to ragdolling.

The problem with zeroing everything out is that your mesh’s default position before ragdolling wasn’t zero / zero rotation to start with. You’ll either want to note down what the rotation and location of the skeletal mesh component is in the blueprint editor viewport or, if you want a more adaptive solution that doesn’t require manually inputting values each time, record the skeletal mesh component’s location and rotation in EventBeginPlay and use those values to restore it back to normal after ragdolling.

Here you can find awesome lessons for advanced return from ragdoll:

2 Likes