DevLog: Implementing Death (Animations) - Violet Weathersby
This week one of my responsibilities was getting the unit (both player characters and enemies) death working. We already had the code for knowing when a unit was dead thanks to the health component, but the characters would continue moving and fighting. This solution was fairly straightforward, add in the code to disable collision and to get the AI controller to stop movement then unpossess the character. Where the problems started was with the animations.
For our project we are using Unreal Engine’s animation graphs. In the first week, I copied work from a previous project where there is a movement state that transitions into a death state when the character dies. However, in that project the actor was destroyed as soon as the death animation was complete. In this project though we wanted to have a variable that controls how long the body remains until disappearing. Making this variable and timer went well, except that the death animation looped.
To fix this problem I added a PauseAnimation function into the parent C++ class of all of the AnimInstance blueprints. This function would use a reference to the last “PlaySlotAnimationAsDynamicMontage” montage, which I also had to create, and call Montage_Pause. It wasn’t until just now that I saw the description of the Montage_Pause function.
It doesn’t need to have that reference to the current montage. Instead of creating a function the base squad class could just call AnimInstance->Montage_Pause(). (Probably, I haven’t actually tested it.)
So, even if it wasn’t the most efficient solution, the problem was solved, right? For the heroes, it was working, but when the orc enemies died the animation wasn’t playing. They would do this:
(which is the mesh’s default pose.)
The source of the problem was in the animation graph.
The Anim_Death is the name of the human animation asset specifically. The orc needs to be playing an animation called Anim_Orc_Death_Orc_Death. When I created the separate AnimInstance blueprints I created the human one, then copied it and swapped out the asset variables.
There were two possible solutions for this problem. The first would be to go into each of the animation graphs and hard code the death asset into the death state like it was for the humans. The second was to remove the sequence player from the death state and to call PlaySlotAnimationAsDynamicMontage for the death animation in code like the attack and hurt animations. I decided to use the second solution since in general it’s best to avoid hard coding things. This way if we want to swap out the death animation, we can just change the variable instead of having to edit the graph.
Once that code was implemented, I was done with this task, and our units were finally dropping dead properly!
Get Return to Divinity
Return to Divinity
Strategic combat, tactical formations, and perilous dungeon runs—can you survive the depths?
Status | Released |
Authors | Good Faith Company, VioletJoy, UnmakerOfThoughts, John Ivess, Senia Icethief |
Genre | Adventure, Action, Role Playing |
Tags | Dungeon Crawler, Fantasy, Isometric, Medieval, Perma Death, Real time strategy, Roguelike, Singleplayer |
More posts
- Devlog: Implementing a Status Effects system - Ivan Shyika48 days ago
- Devlog: Refactoring Items and TraderActor - Ivan Shyika55 days ago
- Devlog: Technical design of the Inventory System - Ivan Shyika63 days ago
- Devlog: Overhauling Squad Movement and Formations - Keegen Love71 days ago
- Devlog: Hero Classes and Special Abilities - Ivan Shyika71 days ago
- Devlog: Preserving squad data across levels - Ivan Shyika77 days ago
- DevLog: Squad Selection Crashes - Violet Weathersby77 days ago
- Devlog: Fixing Squad AI Freezing in Combat: A Deep Dive into Task Instancing and...77 days ago
- DevLog: Camera Issues - Adam Denomme77 days ago
Leave a comment
Log in with itch.io to leave a comment.