Play FBX Animation from C++

How do I play an animation that was included in the FBX from C++?

There’s only one animation, and it’s rather simple. I would think that it would be equally simple to play this type of animation but I haven’t had any luck thus far.

I have the USkeletalMeshComponent, and I can see animation attributes from it, including the AnimScriptInstance but can’t figure out how to get it to play.

How do you play an animation?

Thank you.

you need to make an AnimMontage out of it first, then play that one
I requested this functionality to play an Anim directly from code a long time ago (like we could in UDK), but it went ignored :frowning:

This would definitely be quite useful! As well as anim flow control - like in BPs

Thank you Chosker.

Outside of this sparsely useful documentation, (Animation Montage in Unreal Engine | Unreal Engine 5.2 Documentation), do you know of any other documentation I can refer to?

If you look at BTTask_PlayAnimation.cpp you can see how the Behavior Tree system plays animations, you can even toss in a break point to break things down further and follow the code line by line if needed.

Thank you for the tip ExtraLifeMatt. I’ll keep that in mind for animations that will be coming up in the near future. Fortunately I was able to get my current animation to play on demand now. There certainly looks like a lot of goodies in there though (montage, etc.).

Do you by chance have any AI experience? I’m trying to get my enemy to patrol, attack, and retreat as needed using the floating component. I have another thread for this question though.

well isn’t that convenient, thanks for the info

apparently they actually added a function PlayAnimation() into USkeletalMeshComponent, they just never said it :eek:

Sneaky Epic…