UAnimInstance::GetSkelMeshComponent
#include "Animation/AnimInstance.h"
Access: public
Specifiers: inlineconst
Description
Returns the USkeletalMeshComponent that owns this anim instance. The returned pointer is always valid in a live instance — this is the primary way to access the mesh, its bone transforms, and its physics state from within an anim instance.
Caveats & Gotchas
- • Internally delegates to GetSkelMeshComponentChecked(), which asserts on failure. If you need a safe non-asserting version (e.g. in early initialization), use GetSkelMeshComponentUnchecked() instead.
- • Calling this before the anim instance is fully initialized (e.g. inside the UObject constructor) can return nullptr or trigger the assert. Wait until NativeInitializeAnimation or later.
Signature
inline USkeletalMeshComponent* GetSkelMeshComponent() const Return Type
USkeletalMeshComponent* Example
Accessing mesh properties from inside an anim instance C++
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
USkeletalMeshComponent* Mesh = GetSkelMeshComponent();
ACharacter* Owner = Cast<ACharacter>(Mesh->GetOwner());
if (Owner)
{
bIsMoving = Owner->GetVelocity().SizeSquared() > 1.0f;
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?