RealDocs

UAnimInstance::LinkAnimGraphByTag

function Engine Blueprint Since 4.24
#include "Animation/AnimInstance.h"
Access: public Specifiers: UFUNCTIONBlueprintCallable

Description

Swaps the class running inside a Linked Anim Graph node identified by tag to a different UAnimInstance subclass at runtime. Useful for dynamically changing sub-graph behaviour (e.g. switching between weapon-specific animations).

Caveats & Gotchas

  • The switch takes effect at the start of the next animation evaluation frame — there is a one-tick delay between calling this and the new class becoming active. If you query GetLinkedAnimGraphInstanceByTag immediately after, you may still get the old instance.
  • Passing a null InClass resets the linked node to its default class as set in the AnimGraph. State on the previous instance is lost immediately.

Signature

ENGINE_API void LinkAnimGraphByTag(FName InTag, TSubclassOf<UAnimInstance> InClass);

Parameters

Name Type Description Default
InTag FName Tag of the Linked Anim Graph node to retarget.
InClass TSubclassOf<UAnimInstance> The new anim instance class to run inside the linked graph node.

Return Type

void

Example

Switching a weapon sub-graph to a rifle animation class C++
// Called when player equips a rifle:
void AMyCharacter::OnEquipRifle()
{
    if (UAnimInstance* AnimInst = GetMesh()->GetAnimInstance())
    {
        AnimInst->LinkAnimGraphByTag(FName("WeaponGraph"), URifleAnimInstance::StaticClass());
    }
}

Version History

Introduced in: 4.24

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.