Posted July 12, 2024 by MysticF0x
Switching attacks
Author: Eyon Norman
07/11/2024
The Problem:
This week i was tasked with getting our first boss set up and in a working state. And with that means i would need more than the single attack that our normal base enemy does. I would also want the behavior of the boss to not really do the same attack over and over. This comes with a problem in of itself. How do you make your boss attack with multiple attack montages? You could straight program it but then the boss seems to predictable. So i went with something else instead. Behavior trees!
The solution:
Like i said before a simple and straight forward approach to this problem is just hard code the attack sequence. The boss does 1 attack then another, then another. But i didnt want our boss to be like that. So instead I took the problem and threw it at a behavior tree. So first i needed to create a couple attack events that play different animations in our boss blueprint. From there i created a Enum that houses names for the attacks that i want for the boss(currently only 2 but there will be much more later) After that i created a simple behavior tree and then created a behavior tree task that calls these attacks by name from a switch. I made a simple decorator that passes a random float to put on the BTTask. And the only thing left from there was to put the decorator on one of the attacks that way, if the attack with the decorator didnt go off the next animation would. And that is how i make the boss able to play multiple attack montages without hard coding a sequence