Switch behavior trees while active

I have my AI run one behavior tree by default and that behavior tree contains everything to act as a normal citizen.
This behavior tree also checks to see at any time to see if the NPC has changed to a “Guard” or a “Infected State” and for each I want separate tree for Citizen/Guard/Infected State, each with their own individual blackboard.
I try and run one of them from one behavior tree and if they have any blackboard set other than the one that the default tree has they wont execute.

1 Like

I found a way around this. If there is a better way to do this please let me know.
What I did was created a new task that stopped the current tree and then executed a different tree.

You could try this:

Thank you, this worked a lot better and more efficient compared to my last way of doing it.

What I would do is create three different AIController subclasses, and remove the old controller and instantiate a new controller, based on the behavior I want the pawn to have.

1 Like

Okay. I have a question. I set mine up similar but I want to use a boolean to go back and forward with controlled or not controlled. I have it set up to when the beam overlaps the friendly AI they become controlled and start to attack the player character. The problem is its stuck on controlled and keep attack the player. How do I have it change back to Friendly AI Uncontrolled? At the end I set isYitilba? to off but it dosent even fire nor does the print string at the end that say “Yitilba Over”. The Friendly follows the player character and when the player capsule collides with the beam The friendly attacks the player character. Now how do I simply go back to Friendly AI following the player and stop the attacking witch is Controlled? Thank you.