Hi all
I’m trying to set my character to ragdoll and then get back up. The first part seems to work just fine, but the latter has major issues.
Setting the ragdoll is done like follows and it works fine:
RagdollBlendOut = 1.f; // Variable to track blending out from ragdoll
GetPawnMesh()->SetAllBodiesBelowSimulatePhysics(FName("root"), true);
GetPawnMesh()->SetCollisionProfileName(FName("Ragdoll"));
Getting back into animated mesh I have following code in place. First I put the rigid bodies to sleep:
GetPawnMesh()->PutAllRigidBodiesToSleep();
then I do in tick function the following blending:
RagdollBlendOut -= DeltaSeconds / RagdollBlendOutDelay;
if (RagdollBlendOut <= 0.f) // Blended out completely
{
RagdollBlendOut = 0.f;
GetPawnMesh()->SetAllBodiesBelowSimulatePhysics(FName("root"), false);
GetPawnMesh()->SetCollisionProfileName(FName("CharacterMesh"));
}
else // Still blending
{
GetPawnMesh()->SetAllBodiesBelowPhysicsBlendWeight(FName("root"), RagdollBlendOut, true);
}
The problem is that when it’s blending back from ragdoll, the character starts to move/spin wildly. And wildly in here means that it can even end into 100m into the sky, or even outside of skybox. I have noticed that the longer the blending in time is, the more wildly it flies away. The blending time doesn’t affect otherwise than how far it will end up. The motion is just as violent. If I just end the simulation without blending, the mesh ends up under/side of the capsule component, upside down or partially sideways. The mesh also stops following the capsule component after this. I can see all animations playing on the mesh when the capsule component moves, but its not following the capsule anymore.
Any idea what could be wrong and/or what to try out? I can provide further information on my implementation if that helps resolving the issue. I tried also similar approach than explained here [link text][1], but the same spin/move problem persists.
The skeleton I have looks like this:
My character looks like this:
One random note. The root bone is still part of the simulation even when using SetAllBodiesBelowSimulatePhysics. Only when I select whole upper body, the root bone stays in place. I assigned a camera into it and saw it moving wildly. To my understanding only the bones under specifiec bone should be part of the simulation, right? Is this normal?