How to manage players animations

I have started making my first project in UE5 and Im unsure about how animations should be managed/used for my player. I have a simple FPS player controller that has animations for walking, attacking and so on. Coming from Unity I would have all of my animations in the animator (animation BP), however a lot of tutorials I have seen for UE5, they play the attack animations in the players BP using PlayAnimMontage while having walk and Idle in the animation BP. Is this architecture considered good, because I would like my animations to be in one spot.

1 Like

You can do whatever way you want.
In general, though, jamming action animations into the animation blueprint leads to more coupling.
Consider if you want to implement the feature “pet the dog.”
If you have all animation control in the animation blueprint, then you need to add some flag/state that says “petting the dog,” and then update the state machine to transition to that action, and then update the player character to set the appropriate attributes to make that work.
This works but it gets very messy as the game grows.

The alternative, is to build some “Player Action” class, and part of a player action is an animation montage to play, and maybe some code to run, and so on.
Now, you implement “perform action” as the single operation on the player character, and it will take the Action object, and apply the appropriate animation and so on, based on the data in the Action object.
Now, it’s easy to make a “pet the dog” action, and then a “pick up object” action, and then a “lie down and rest” action – each of them can be built in their own subclass of Action, rather than having to update a bunch of different places to match up.

With Blueprints, you can even add custom code to these “performable actions” in some event dispatcher that the player character calls when beginning and ending actions (for example.) In your custom blueprint subclass, make the “end action” callback play a sound, or make the “start action” spawn a sparkly particle system, or whatever.

(Once you are familiar with this way of decomposing objects, you will then want to look at the Gameplay Ability System, which takes this idea, and then pushes it a few more miles forward, which is great for really big and complex games, but you can probably hold off on that for quite a while.)

1 Like

Your alternative sounds really good, tell me if this is what you meant.

I made a BP called PlayerAction_Base that has this function
image
This logic gets called from the child Bp class PlayerAction_SlashLeft

Now in the player BP when I need the animation to play I call this function
image
which uses the reference of the child BP PlayerAction_SlashLeft object ref as the target.

What I have right now is on BegingPlay it will call ConstructActions where its spawning an actor from the action class and sets the reference.

That looks like it should work!
You should probably make sure that the action gets deleted when it’s done somehow. (Exactly how to know when an action is “done” is an interesting problem in itself …)