UAnimInstance::GetLinkedAnimLayerInstanceByGroupAndClass
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTIONBlueprintPureconst
Description
Returns the linked layer instance that matches both the specified group name and the specified class. More precise than GetLinkedAnimLayerInstanceByGroup when multiple classes may be linked to the same group at different times.
Caveats & Gotchas
- • Returns nullptr if the group exists but its current instance does not match InClass — for example after calling LinkAnimClassLayers with a different class. Do not cache the result across frames without re-querying.
- • Does not check child classes by default; the instance's class must exactly match InClass (IsA check). Use GetLinkedAnimLayerInstanceByClass with bCheckForChildClass=true if you need polymorphic matching.
Signature
ENGINE_API UAnimInstance* GetLinkedAnimLayerInstanceByGroupAndClass(FName InGroup, TSubclassOf<UAnimInstance> InClass) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InGroup | FName | The group name of the linked layer to search. | — |
| InClass | TSubclassOf<UAnimInstance> | The anim instance class the returned instance must be an instance of. | — |
Return Type
UAnimInstance* Example
Safely retrieving a typed layer instance when multiple classes are possible C++
// Useful when your character can link different weapon classes to the same group:
UAnimInstance* Inst = GetLinkedAnimLayerInstanceByGroupAndClass(
FName("WeaponGroup"),
URifleAnimInstance::StaticClass()
);
if (URifleAnimInstance* RifleAnim = Cast<URifleAnimInstance>(Inst))
{
RifleAnim->SetReloadPhase(EReloadPhase::Grabbing);
} See Also
Tags
Version History
Introduced in: 4.24
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?