Goal: To make it so on death my enemy character ragdolls and falls apart.
Problem: The character ragdolls but no parts fall off.
I have a character bp with a skeletal mesh, skeleton, and animations. Also there is a physics asset for the same character. When I run it in the Phat tool the character simulates a ragdoll just fine and if I sent any constraints to linear breakable true in the tool the parts fall off just fine. On my level I have dragged the character bp into the level.
To accomplish the ragdoll I do the following in the animinstance …
//Ragdoll
USkeletalMeshComponent* SkeletalMesh = Robot->GetMesh();
SkeletalMesh->SetSimulatePhysics(true);
SkeletalMesh->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
SkeletalMesh->SetCollisionProfileName("Ragdoll");
Robot->GetCharacterMovement()->DisableMovement();
To accomplish the joints breaking in game on death in the animinstance class I do the following …
USkeletalMeshComponent* SkeletalMesh = GetSkelMeshComponent();
//Get list of what we should break from the robot
TArray<FString>* BreakableJoints = GetRobotCharacter()->GetBreakableJoints();
TArray< struct FConstraintInstance * > Constraints = SkeletalMesh->Constraints;
for (int32 i = 0; i < (*BreakableJoints).Num(); ++i)
{
FString BreakableJoint = (*BreakableJoints)*;
bool found = false;
for (int32 j = 0; j < Constraints.Num(); ++j)
{
FConstraintInstance CurrentJoint = *Constraints[j];
UE_LOG(CC, Log, TEXT("Joint Name: %s"), *CurrentJoint.JointName.ToString());
if (BreakableJoint.Equals(CurrentJoint.JointName.ToString()))
{
CurrentJoint.bLinearBreakable = true;
found = true;
break;
}
}
if (!found)
{
UE_LOG(CC, Log, TEXT("Joint Name: %s Not Found"), *(*BreakableJoints)*);
}
}
Problems with this are
*****1) The parts of the robot don’t fall off like in the phat tool
2) The robot isn’t interacting with other characters in the scene (isn’t kickable)
I also tried setting the LinearBreakThreshold = 0 on the joint.
I’m really at a loss… why don’t the joints break like in the Phat Editor when setting the linear breakable flag to true?