Today I decided to make a start on the AI for the boomshroom as I feel the AI for the enemies will take the longest amount of time to complete.
I wanted to tackle each state of the boomshroom in the order that they are executed within the AI overview above. This would allow me to gradually build the functionality of the boomshroom and would bring up any issues with the different states in the order that they will appear.
I started by making an first draft at the service for choosing whether the boomshroom is active or inactive. If the player overlapped the trigger radius of the boomshroom the name of the player would be printed to the screen using the print string in the blueprint above. I made a basic version of this before adding the functionality to the different states because I wanted to make sure that the overlap was working correctly.
Using blackboard keys I changed the boomshrooms state from inactive to active when the player overlaps the boomshrooms trigger radius.
After the boomshroom launches itself from the ground, the state of the boomshroom changes to a walk state using the behaviour tree task below. Changing states aborts the triggered sequence and activates the walk sequence. The walk sequence finds the players current location, waits a few seconds, then moves to the players location and changes states to the plant mine state which I will talk about in the next section.
When I was creating this section I ran into a lot of problem because when I was changing states and aborting the first sequence, it would not execute the walk state. This was due to me using a sequence instead of a selector as sequences only run from left to right if the task succeeds whereas a selector moves from left to right if the task fails. Now that I understand this workflow I should not run into this issue again.
While watching the tutorial above, I discovered that you can change the variables that you set within the blackboard through the player blueprint. Using this knowledge it allowed me to change the state of the enemy by calling a custom event through the behaviour tree.
Above show the system I used to change the states of the boomshroom using custom events with the boomshroom blueprint
When the mushroom walks to their desired location the plant mine state will be entered which spawns a mine at the boomshrooms current location. When this has been completed the boomshroom will return to the walk state. The next step will be putting a limit on how many mines the boomshroom can place before they decide to run towards the player and explode.
Rees, O (2019). Boomshroom AI overview. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Triggering the boomshroom. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Boomshroom behaviour tree that set triggers the mushroom. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Initial check for trigger service. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Check for trigger service that changes the state from inactive to triggered. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Triggering the boomshroom and moving it towards the player. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Behaviour tree setup for the walk state. [offline]. [Accessed 08/02/2019].
Looman, T (2019). [online]. Unreal Engine AI Tutorial: Create Artificial Intelligence with Behavior Trees. YouTube [video]. 1 January. Available from: https://www.youtube.com/watch?v=tq-ULFuNyig [Accessed 08/02/2019].
Rees, O (2019). Behaviour tree task ChangeState using a switch to easily change between states. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Changing the states using custom events within the boomshroom blueprint. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Boomshroom planting mines. [offline]. [Accessed 08/02/2019].
Rees, O (2019). Behaviour tree mine state setup. [offline]. [Accessed 08/02/2019].