(On 4.27)
Every time my characters switch weapons, they unlink the old weapon’s set of AnimClassLayers and link in the new weapon’s set of AnimClassLayers, via UnlinkAnimClassLayers(Class) and LinkAnimClassLayers(Class) respectively.
However I found that LinkedAnimGraphs that some of those AnimClassLayers might utilize are not successfully unlinked, and linger on the USkeletalMeshComponent, and are there to stay.
After switching weapons a bunch of times, the list logged by this code
if (const USkeletalMeshComponent* SkelMeshComp = GetSkelMeshComponent())
{
for (auto It = SkelMeshComp->GetLinkedAnimInstances().CreateConstIterator(); It; ++It)
{
const UAnimInstance* LinkedAnimInstance = *It;
UE_LOG(LogTemp, Display, TEXT("Linked anim instance is: %s"), *GetNameSafe(LinkedAnimInstance))
}
}
… becomes really big, bringing down my FPS, as shown by UnrealInsights:
Is linking and unlinking anim class layers when switching weapons no longer a valid usecase? Or is that I’m not supposed to be using LinkedAnimGraphs within those class layers? And if this is a valid usecase of both, what’s the best way to clear out those lingering LinkedAnimGraphs via C++?
Thanks for the help!