Download

Going to ragdoll teleports my mesh away

Hello,

we are developing a game which is in 3d, but with a 2d camera look (like a side scroller).

We would like to make our character go in ragdoll when he dies, but we actually face a very strange problem:

as soon as we start the physics simulation on the skeletal mesh, it is teleported in the direction of the camera by several hundreds of units, and only then starts to fall down because of the gravity…

Here is the code which triggers the ragdoll:


void ASQCharacter::GoRagDoll()
{
    GetCapsuleComponent()->SetCollisionEnabled( ECollisionEnabled::NoCollision );
    GetCapsuleComponent()->SetCollisionResponseToAllChannels( ECR_Ignore );

    GetMesh()->SetCollisionProfileName( FName( "RagDoll" ) ); 
    GetMesh()->SetAllBodiesSimulatePhysics( true );
    GetMesh()->GetBodyInstance()->SetSimulatePhysics( true );
    GetMesh()->SetAllPhysicsLinearVelocity( FVector::ZeroVector );
    GetMesh()->SetAllPhysicsAngularVelocity( FVector::ZeroVector );
    GetMesh()->bBlendPhysics = true;
    GetMesh()->WakeAllRigidBodies();

    GetCharacterMovement()->StopMovementImmediately();
    GetCharacterMovement()->DisableMovement();
    GetCharacterMovement()->SetComponentTickEnabled( false );
}

Here are 2 screenshots to illustrate what is going on:

Before:
before.png

After:
after.png

I debugged the transform of the mesh component in the code base, and it appears that it’s Physx which is the culprit, which is confirmed by those screenshots of the Physx Visual Debugger:

Before:
ef73e6ce10599eefaec30a44a80b8bddb52bfb23.png

After:
80cb42b9a73377c2583a421014d6d3bbaaa8ad7c.png

I really don’t know why physics pushes my mesh away like that, since there is no other collision than what is under the character.

For the record, here are what I tried to solve the issue, with no other outcome:

  • Very simple physics asset
  • Offset the mesh upwards a bit so it doesnt touch the ground
  • Reduce the amount of code to just setting the collision profile name to “RagDoll” and SetAllBodiesSimulatePhysics
  • Use blueprint instead of C++

What I don’t understand either is that:

  • by using the mannequin of Unreal instead of our own model, I have the same issues.
  • If I use our model in the TPS sample project instead of the mannequin, it works well.
  • And the strangest of all: if I use our skeletal mesh in our project, unpossess the pawn, and using the details panel, manually set the collision profile name to “RagDoll” and check the Simulate Physics box, it works as expected…

It’s been 2 days I’m desperatly trying to find a solution, but I’m running out of ideas.

What do you think can cause this weird issue?

Thanks !