Stop AI Behaviour Tree

Is there a way to stop the AI behaviour tree from running? In the AIController module you specify it to run with Event begin play → run behaviour tree and tell it which behaviour tree to run… All this is fine. I’m looking for a way to stop running the behaviour tree. The reason for doing this is if I kill a pawn I don’t need the behaviour tree to keep running (saving cycles) until the actor is respawned. Is there a way to do this in blueprints?

1 Like

You need to call StopLogic on AIController.BrainComponent (available in BP as well).

Cheers,

–mieszko

7 Likes

@MieszkoZ there is nothing called StopLogic when casting to the BrainComponent, or in the controller for that matter. I’ve tried both context sensitive and non context sensitive searches. And the actual bot controller which is derived from AIController only contains an ActionsComp which is the pawn actions.

I’ve tried searching for stop logic or anything similarly called wherever I could think of including other valid casts but can’t find this. Is there anything I’m missing? I’m running UE 4.6.1

1 Like

I upgraded my project to 4.7 p2 and it is available there but does not exist in 4.6.1.

Not sure if you ever figured something out but you could simply call an event on the actor you want to kill and have it run destroy actor.

If applicable to the type of game you’re making, you can also make a ‘Dead’ state that you can switch the behavior tree to which would do nothing - assuming you make the AI only wait in that state - until you are ready to destroy the actor.

Seems to work fine for me. Just like Mieszko said…

.
I am using this on my Character, right after processing incoming damage. But you could use it in other places just as well I imagine.

3 Likes

Sorry for bothering man, but to what are you connected the GET AI CONTROLLER?

2 Likes

Please Nick, I’m getting stuck with this for two days.

Please, first go through the game play framework documentation, then ask such a question…

1 Like

i have found that just simply using Unposses will stop the Logic in 4.19 there is a option in the Ai Conroller that if you tick will stop all logic on unposses. not sure if this helps

Thank you! I tried Stop Logic but it doesn’t work. Unposses on the owner controller works perfect!

Hi. Can you also select the node “run behavior tree” and leave the value as null? Isn’t this the same as stopping the behavior tree?

The solution doesn’t work for me and I still can’t stop the behavior tree (5.3)

“Stop AILogic on unpossess” is checked by default:

I’ve tried to call it anyway since it doesn’t has effect, then call unpossess, and even tried to destroy the controller (nodes are correctly triggered, the character is effectively unpossessed):

Behavior tree still running :

image

I’m using a custom Ai controller class that I spawn to control the player character when it needs to automatically walks somewhere with pathfinding, then the player controller controls it back once destination reached. That works, but I would like to get rid of the Ai controller and behavior tree when not needed. For the moment they doesn’t exist until they are needeed, then they never disappear.