Triggering Animations in UE4's Animation State Machine | Tech Discussion
Being as Mythicism is a 3rd person game, we decided to use the Third Person Character template as a base for our player. The Third Person Character template used its blueprint for handling movement and user input, while its animation blueprint passively detected the player's speed and airborne status to change its animation state.
As we began protyping, we obviously needed to include more actions for the player than just moving around and jumping. We included things like rolling and attacking and initially accomplished this by playing animation montages directly from the player's blueprint when the conditions were right.
However setting it up this way had some problems:
- It tightly coupled the player blueprint to particular animation files
- It scattered the logic for playing animations between the player blueprint and the player's animation blueprint
- It failed to provide control over which states animations transitioned to/from
- It bloated up our project with Animation Montage files for each Animation Sequence file we wanted to use
This week I was tasked with finding a way to resolve the above problems with our current player actions in a manner that could be built upon for future player actions. I decided to go about this by migrating all the logic for playing animations to the animation blueprint, where the animation state machine could manage all the state changes. The player blueprint would then need to somehow indirectly trigger events in the animation state machine. But how could I accomplish this?
In Unity3D there is a kind of animation parameter that can be used for state transistioning called a Trigger. Triggers are simply booleans that get automatically reset after the state transition occurs.
I recreated this functionality in Unreal by making a component called AnimationTriggers and attaching it to the player blueprint. The AnimationTriggers component would house the public booleans for the player blueprint to access. Here's an example of some of the triggers I started with:
[From our tech document]
The player blueprint would then use this componet to indirectly communicate to the animation state machine, thus fixing the coupling problem. When one of the booleans is set to true from the player blueprint, it can be thought of as sending out a request to the animation state machine for that animation to occur. The animation blueprint is then responsible for responding to that request and resetting the trigger when the action is available again.
[From our tech document]
[From our tech document]
[From our tech document]
The other problems are solved as well with this solution:
- Logical scattering -> All animation logic encapsulated in animation blueprint
- Lack of control for state transitions -> Animation state machine handles state transistions with blending
- Excessive Animation Montage files -> Only Animation Sequence files are needed for animation state machine
The AnimationTriggers component may need to provide addition info in the future such as combo number for combat, but that's all I'll go into for this discussion.
Author: Reilly da Silva
Get Mythicism
Mythicism
Status | In development |
Author | Arcane Studios |
Genre | Action |
Tags | 3D, Action-Adventure, Dungeon Crawler, Fantasy, Singleplayer, Third Person |
More posts
- DOT Particle Effect Not Working In Release Build | Tech DiscussionJun 24, 2022
- Tech Discussion | Boss Post MortemJun 23, 2022
- Ranged Enemy Aiming Problem | Tech DiscussionJun 17, 2022
- A Problem With Blade Trails | Tech DiscussionJun 10, 2022
- Tech Discussion | Boss BehaviorJun 10, 2022
- How To Edit Animation Sequences (Additive Layer Tracks) In UE4 | Tech DiscussionJun 03, 2022
- Tech Discussion | Altar System and Player levelingMay 23, 2022
- Tech Discussion | Save SystemMay 23, 2022
- Adding Varied Footstep Sounds | Tech DiscussionMay 15, 2022
- Designing A Souls-like Block Mechanic In UE4 | Tech DiscussionMay 14, 2022
Leave a comment
Log in with itch.io to leave a comment.