UAnimInstance::GetLinkedAnimLayerInstanceByClass
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTIONBlueprintPureconst
Description
Returns the first linked layer instance whose class matches InClass, optionally allowing derived classes when bCheckForChildClass is true. The simplest query when you know exactly which anim class is linked and only need to access it.
Caveats & Gotchas
- • Only returns the first matching instance. If multiple layer nodes link the same class (uncommon but possible with ungrouped layers), call GetLinkedAnimLayerInstancesByGroup(NAME_None) and filter manually to get all of them.
- • When bCheckForChildClass is false (the default) the match is exact — passing a base class will not find an instance of a derived class. Set bCheckForChildClass=true if you are querying against a base interface class.
Signature
ENGINE_API UAnimInstance* GetLinkedAnimLayerInstanceByClass(TSubclassOf<UAnimInstance> InClass, bool bCheckForChildClass = false) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InClass | TSubclassOf<UAnimInstance> | The class to search for among linked layer instances. | — |
| bCheckForChildClass | bool | If true, also matches instances of classes derived from InClass via IsChildOf. | false |
Return Type
UAnimInstance* Example
Accessing a linked layer instance by class after equipping a weapon C++
// After calling AnimInst->LinkAnimClassLayers(URifleAnimInstance::StaticClass()):
if (URifleAnimInstance* RifleAnim = Cast<URifleAnimInstance>(
GetMesh()->GetAnimInstance()->GetLinkedAnimLayerInstanceByClass(URifleAnimInstance::StaticClass())))
{
RifleAnim->SetIsFiring(true);
} See Also
Tags
Version History
Introduced in: 4.24
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?