Debugging Buggy Bugs
by William Terlop
This week there was not a lot of feedback on the project so I was left to simply work from the backlog. I had two major issues this sprint; one was a defect with the animation of an enemy and one was a major source control issue that cost me an entire day of development.
One defect from each sprint that has haunted me has been the crawling bug death animation. It took a lot of time and effort to determine why this was even happening, but it took even more time to determine the fix! What I noticed was happening was at random the enemy death animation was not playing when their health reached zero.
After several hours of debugging I’m still not sure of what issue was “the” issue. Here are some of the things I found while testing and things I tried to solve the issue:
Issue: Enemy being shot while the death animation was playing would cause an interrupt and revert back to the idle state as shown above.
So for this I immediately turned off all collision the tick the enemy death animation was played. This solved two issues I was having.
First issue was the death animation was no longer interrupted by the player shot.
Second it allowed the player to walk through the enemies. This was important because on the platforming sections of the molten metal factory had enemies on small platforms. When the player was moving through at a quick pace the collision of a dead enemy would cause the player to be pushed off the platform.
Issue: I noticed that the enemy being killed during the bite/attack animation would prevent the death animation from being played.
This was the most difficult issue to solve as I was mixing several different ways of playing an animation. First there was animation blueprint ready to play the death animation when the variable was set. Second, the blue prints had a path to play this animation when the enemy health was less than or below 0. So the first thing I did was delete the variable from the animation blueprint. I feel like using the animation blueprint was the correct way to solve this issue. But because of the simplicity of prototyping via blueprint I went that route.
I removed the variable from the animation blueprint to make only one place the animation was being played.
I also added various print statements to check if the animation was actually being triggered… it was.
I added a boolean state to the behavior tree to ensure that all AI behaviour was blocked when the enemy was killed.
What seemed to solve the issue was disabling all AI behaviors when the enemy was killed and also disabling the enemy controller the moment their health was at or below zero. This seemed to be the perfect combination to get the issue solved. It sounds simple when writing or reading about it. But it took a lot of trial and error to get it solved. It was worth it though, knowing the the enemy death animation will play every single time. Its a better experience for the player!