Undo ragdoll

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.