Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Modular Behavior Tree Design

My primary focus for development of Heroes' Blunder is to be handling AI. On the surface it sounds easy, but it is far more complex than most imagine as they have not taken the dive into the realm of Behavior Trees, Blackboards, Tasks and Services.
For the most part, tutorials will dive into very focused types of AI, not taking into account re-usability of the Tasks and Services, for example an AI that runs away would have a couple tasks and maybe a service. These are very much linked to variables stored in the Behavior Trees themselves and limit the scope in which that Behavior Tree can scope.

My goal was to break from that mold and utilize a more modular approach to Behavior Trees. In an effort to allow rapid development of multiple AI behaviors that can be implemented on multiple different actors, I had to deploy the system with modularity in mind. What does that mean?


The first thing that meant was that the AI Controller and Base AI Actor class needed to provide common functionality that will be required across all potential Behavior Trees developed. Storing specific variables such as walk, chase, investigate and return speed multipliers that can be changed on a per-actor basis with some corresponding Behavior Tasks for setting the speed of the Actor to the correct variable stored on the Actor's class.


Beyond that the next step was to design small deployable Behavior Tasks that will be common across multiple different expected Behavior Trees for the AI that will need to be implemented for the game. Some of these include clearing a Blackboard value, Attacking, Finding a Random Location within a specified range, Setting Target Location to Spawn Point and Setting the Direction to be Facing.


Along with the Tasks, Services are needed for things such as checking if the actor is within their pursuit range, reengagement range and attack range. With these foundations, many varied Behavior Trees can be forged by mixing and matching the various elements and adjusting variables on the Actor individually to provide a level of customization and a range to the "feel" of the behaviors.


When you're designing your AI, consider taking a modular approach if you plan to have multiple AI Behaviors that will have commonly shared elements as you can potentially save yourself days of development by spending a couple of hours creating the foundations to a dynamic exciting system that is surprisingly simple in implementation.

author: Clinton Butler
Posted on 5/12/2023

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.