How to use USkeletalMeshComponent::PlayAnimation

Im trying to play an animation from cpp code, just like the Play Animation node in blueprints, but i cant find any tutorials on how to use the cpp syntax.

or if theres another way to do this lmk pleas

void PlayAnimation
(
    class UAnimationAsset * MyThiccAnimation,
    bool bLooping
)
1 Like

Hey,

whatever.h
// set this in editor to the animation you want to trigger
UPROPERTY(EditDefaultsOnly)
UAnimationAsset* MyAnimation

whatever.cpp
// this shoots the pre-set animation. should be used after beginplay
MeshComp->PlayAnimation(MyAnimation, false);
1 Like

awesome ty

1 Like