Description

UDebugSkelMeshComponent and PreviewInstance are lost current animation asset.

There are 2 ways to fix below

void UDebugSkelMeshComponent::InitAnim(bool bForceReinit)
{
	// If we already have PreviewInstnace and its asset's Skeleton does not match with mesh's Skeleton
	// then we need to clear it up to avoid an issue
	if ( PreviewInstance && PreviewInstance->GetCurrentAsset() && SkeletalMesh )
	{
		if ( PreviewInstance->GetCurrentAsset()->GetSkeleton() != SkeletalMesh->Skeleton )
		{
			// if it doesn't match, just clear it
			PreviewInstance->SetAnimationAsset(NULL);
		}
	}

#if 0
	if (PreviewInstance != nullptr && AnimScriptInstance == PreviewInstance && bForceReinit)
#else
	if (PreviewInstance != nullptr && bForceReinit)
#endif
	{
		// Reset current animation data
		AnimationData.PopulateFrom(PreviewInstance);
		AnimationData.Initialize(PreviewInstance);
	}

	Super::InitAnim(bForceReinit);

or

	for (UObject* Obj : ObjectsReplaced)
	{
		UObject** NewObject = OldToNewInstanceMap.Find(Obj);
		if (NewObject && *NewObject)
		{
			if (UAnimInstance* AnimTree = Cast<UAnimInstance>(*NewObject))
			{
				// Initialising the anim instance isn't enough to correctly set up the skeletal mesh again in a
				// paused world, need to initialise the skeletal mesh component that contains the anim instance.
				if (USkeletalMeshComponent* SkelComponent = Cast<USkeletalMeshComponent>(AnimTree->GetOuter()))
				{
//					SkelComponent->ClearAnimScriptInstance(); // remove
					SkelComponent->InitAnim(true);
					// compile change ignores motion vector, so ignore this. 
					SkelComponent->ClearMotionVector();
				}
			}
		}
	}

The easiest workaround is to reopen the preview window and reset the current animation.

Steps to Reproduce
  1. open attached project on 4.22 [Link Removed]
  2. click /Content/Mannequin/Animations/ThirdPersonRun in content browser to open animation preview
  3. click /Content/Mannequin/Animations/PostAnimBP in content browser
  4. reconnect a node in animgraph in PostAnimBP to make BP dirty
  5. compile PostAnimBP
  6. see animation preview window

Result

A mannequin loses a running animation in animation preview.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-96266 in the post.

1
Login to Vote

Fixed
ComponentUE - Anim - Runtime - Anim Blueprints
Affects Versions4.224.234.244.255.1
Target Fix5.1
Fix Commit20278272
Main Commit20282219
CreatedAug 3, 2020
ResolvedMay 19, 2022
UpdatedMay 28, 2022