Skip to main content

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

BehaviorTree + AIController == Troubles && Triumphs - Unreal Engine 5.1

As a new Unreal Engine developer, unpacking the complexities of Behavior Trees and AIControllers with their associated Components provides a challenge for someone coming from Unity and custom engine development. Especially if you try to avoid Blueprints from the start. As it turns out: AIPerceptionComponent can only be safely attached to an AIController, which also requires the addition of an AIPerceptionStimuliSource on the Actor object for your AI in order to effectively link your functionality! If you don't do this, you will either not get any responsiveness from the AIPerceptionComponent or if you put the AIPerceptionComponent directly onto your Actor, you will get warning messages saying that the intended use of that Component is to be inside an AIController object! Without this core, Behavior Trees will have a serious issue in tracking other Actors or Stimuli in order to perform their desired Tasks.

After several days of multiple iterations, I was able to conclude the correct order of operations is:

  1. Create your AI Actor
  2. Create your AIController
  3. Add an AIPerceptionStimuli Component to your AI Actor, specifically setting up the desired stimuli that your AIController will handle
  4. Configure your AIPerceptionComponent in your AIController using the desired stimuli
  5. Create your Behavior Tree
  6. Create your Blackboard
  7. Develop out your Behavior Tree, adjusting your Blackboard as needed, creating new Tasks and Services as needed

It is also wise to create these in Blueprint first, as it is generally a lot easier to track down your problems than having to go back and forth to your IDE to adjust code, then back to the editor to compile/test. Once you have your desired operational structure, you can tackle conversion to C++ for optimization.

This is very dependent upon your development schedule, but if you are still new I truly do advise to take this route otherwise you can spend days chasing your tail in a loop while halting development completely. It is better to spend more time and result in something functional than to spend all of your time with no result at all.

author: Clinton Butler
Posted on 4/22/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.