Animations do not play in Packaged game

Hi all,

Seeing strange behaviour when the game is packaged, whilst it works just fine when playing in-editor.

I current load animations as and when needed through the following method:



        TArray<UObject*> tempArray;
        if (EngineUtils::FindOrLoadAssetsByPath("/Game/Animations/HumanoidAnimations/Male", tempArray, EngineUtils::ATL_Regular))
        {
            UAnimMontage* animation = LoadObject<UAnimMontage>(nullptr, *FString("/Game/Animations/HumanoidAnimations/Male/Blocking"));
        }


I then store this object in an array, and pass the resulting UAnimMontage pointer to an animation class, which has a few RPC calls. The rough structure is below:



void UCharacterAnimationManager::PlayAnimation(ARoguelikeCharacter* character, UAnimMontage* animName)
{
    if (character->HasAuthority())
    {
        MulticastPlayAnimation(character, animName);
    }
    else
    {
        ServerPlayAnimation(character, animName);
    }
}

//here are some multicast and server functions that call PlayAnimationInternal

void UCharacterAnimationManager::PlayAnimationInternal(ARoguelikeCharacter* character, UAnimMontage* animName)
{
.....

    auto result = character->GetMesh()->GetAnimInstance()->Montage_Play(animName, speed);

    UE_LOG(LogTemp, Warning, TEXT("PLAY MONTAGE RESULT : %s"), *FString::SanitizeFloat(result));
......

}


Interestingly this all works fine when playing in-editor, but as soon as the game is packaged, one of two things happens: the game either crashes with a fatal error, or the animation simply does not play.

To try and diagnose this issue, I have seeded a few functions with logging calls, and discovered a few interesting things. The result of the Play_Montage call is always 0 - suggesting an animation is never successfully played. More interesting is when I log the name of the UAnimMontage object I get an inconsistent result, often something totally unrecognisable.

Here are some quick log examples:



//UE_LOG(LogTemp, Warning, TEXT("ANIMATION WAS VALID"));
//UE_LOG(LogTemp, Warning, TEXT("ANIMATION NAME: %s"), *animName->GetName());


Log file:
[2018.08.08-00.19.47:104][485]LogTemp: Warning: ANIMATION NAME: Custom

On a seperate runthrough:
[2018.08.08-00.18.38:670][370]LogTemp: Warning: ANIMATION NAME: Image_29



I am fairly sure the files are correctly loaded - they work in editor, and are definately packaged (if I turn off the .pak option, I can see them in the correct folder, and there is never an exception thrown when initially loading them).

Has anyone else experience strange results when running a game in packaged mode? Is it something to do with the way I am loading anims, something to do with the fact I make an RPC call and pass the UAnimMontage, or something to do with the way I have the packaging configured? Is it something else entirely?

Any and all help, as always, greatly appreciated :slight_smile: