Hi,
I just tried to implement a ragdoll feature in my game. I mostly used the code from the Shooter Example provided by Unreal. Everything seems to work fine but when the ragdoll is activated, the mesh launches up into the air. I also found some threads about ragdolls launching in the air but this is not occuring when I walk over the mesh but when the ragdoll gets active. Sadly “Impart base Angular Velocity” didn’t do the trick for me here.
My Code:
void ABaseCharacter::SetRagdollPhysics()
{
bool bInRagdoll = false;
if (IsPendingKill())
{
bInRagdoll = false;
}
else if (!GetMesh() || !GetMesh()->GetPhysicsAsset())
{
bInRagdoll = false;
}
else
{
// initialize physics/etc
GetMesh()->SetAllBodiesSimulatePhysics(true);
GetMesh()->SetSimulatePhysics(true);
GetMesh()->WakeAllRigidBodies();
GetMesh()->bBlendPhysics = true;
bInRagdoll = true;
}
GetCharacterMovement()->StopMovementImmediately();
GetCharacterMovement()->DisableMovement();
GetCharacterMovement()->SetComponentTickEnabled(false);
if (!bInRagdoll)
{
// hide and set short lifespan
TurnOff();
SetActorHiddenInGame(true);
SetLifeSpan(1.0f);
}
else
{
SetLifeSpan(10.0f);
}
}
http://puu.sh/khTDu/0df9b60714.jpg
Could anyone help me out here?
Thanks
~Theo