Problem getting separated skeletal mesh to properly use physics and gravity

Hello,

I have a zombie character that has separate skeletal meshes for its limbs (arms, legs, and torso). They are all animated with the same animation blueprint. However, when my main character shoots the zombie, I want the limbs to fall off onto the floor (using physics basically). For some reason, I can’t seem to make the limb properly use physics during play mode/runtime.

I will attach my code below, but I’ve tried several things. Lets use the right arm as an example. My right arm skeletal mesh has a physics asset attached to it. During play mode, using C++, I set collision enabled, then I set simulate physics to true, then I set enable gravity to true as well. This actually does absolutely nothing to make the arm drop out of it’s position on the character. The only setting that changes things is if I set “bNoSkeletonUpdate” on the skeletal mesh to true. Then the arm sits there where it was set and if the zombie “dies”, it does it’s death animation, and the arm remains where it was set to “bNoSkeletonUpdate” (i.e. it hangs in the air motionless while my character animates it’s death).

Now the very interesting thing, is that if I (in the editor during playmode), eject myself from the pawn, click on my zombie, and check or uncheck almost any setting whatsoever, the arm drops out of the air onto the floor like I want it to! Why is this the case? I can’t get it to drop using physics during regular playmode, but if I eject myself and check a setting on it, it drops the way I want lol.

Why does simulating physics, and enabling gravity not work?

Can I completely disable or detach the Animation Blueprint from the skeletal mesh limbs to get them to stop animating, or using animation?

Overall, how can I get my zombie’s limbs to fall off during playmode?

Here is the code I’ve tried so far:



// If the other actor that was hit has a tag at array element "0" with the name "SpecialEnemy1" then proceed
   if (Name1 == "SpecialEnemy1")
   {
    //EnemyComponentArray1.Empty();

    // Detaching Skeletal Mesh Component on bullet impact!
    UCapsuleComponent * EnemyCapsuleComponent = OtherActor->FindComponentByClass<UCapsuleComponent>();
    EnemyCapsuleComponent->GetChildrenComponents(true, EnemyComponentArray1);

    int32 TempInt2 = EnemyComponentArray1.Num();
    UE_LOG(LogTemp, Warning, TEXT("%d components in the array"), TempInt2);

    // If the actor component array is populated with something, then continue
    if (EnemyComponentArray1.Num() > 0)
    {
     UE_LOG(LogTemp, Warning, TEXT("Enemy components array is more than zero"));

     FName Name2 = FName("SKCyberzombieArmL");

     // Iterate through all the child skeletal meshes (technically scene components here) and find the component that I want
     for (int32 CompIndex2 = 0; CompIndex2 < EnemyComponentArray1.Num(); ++CompIndex2)
     {
      //UActorComponent* ThisActorComponent = Cast<UActorComponent>(EnemyComponentArray1[CompIndex2]);

      UE_LOG(LogTemp, Warning, TEXT("The name of this component is %s"), *EnemyComponentArray1[CompIndex2]->GetFName().ToString());

      if (EnemyComponentArray1[CompIndex2]->GetFName() == FName("SK_Cyberzombie-ArmR"))
      {
       UE_LOG(LogTemp, Warning, TEXT("Code Code Code 2!"));

       USkeletalMeshComponent* ThisSkeletalMeshComponent = Cast<USkeletalMeshComponent>(EnemyComponentArray1[CompIndex2]);

       // Detach this component from it's parent
       //EnemyComponentArray1[CompIndex2]->DetachFromComponent(FDetachmentTransformRules(EDetachmentRule::KeepWorld, false));
       //EnemyComponentArray1[CompIndex2]->DetachFromParent(false, false);
       //EnemyComponentArray1[CompIndex2]->DetachFromParent(false, false);


       ThisSkeletalMeshComponent->SetDisableAnimCurves(true);
       ThisSkeletalMeshComponent->bNoSkeletonUpdate = true;

       ThisSkeletalMeshComponent->bPauseAnims = true;
       ThisSkeletalMeshComponent->GlobalAnimRateScale = 0;

       //ThisSkeletalMeshComponent->bPauseAnims = false;

       //ThisSkeletalMeshComponent->bPauseAnims = true;


       UAnimCustomParent2* AnimationBlueprintInstance = Cast<UAnimCustomParent2>(ThisSkeletalMeshComponent->GetAnimInstance());

       if (!AnimationBlueprintInstance) return;

       AnimationBlueprintInstance->ShouldDetachLimb = true;

       AnimationBlueprintInstance->UpdateAnimation(0, false);

       //AnimationBlueprintInstance->bPauseAnims = true;

       //ThisSkeletalMeshComponent->SetAllBodiesBelowSimulatePhysics("upperarm_l", true, false);


       ThisSkeletalMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);

       ThisSkeletalMeshComponent->SetSimulatePhysics(true);
       ThisSkeletalMeshComponent->SetEnableGravity(true);


       //ThisSkeletalMeshComponent->SetAllBodiesBelowSimulatePhysics("upperarm_l", true, false);

      }


I’ve also tried having the zombie’s arm enter into an “Empty” animation state on it’s Animation Blueprint, but this does not make the arm fall either.