Is there any way to disable and re-enable a behavior tree

Hi,
I’m currently making enemies in my game and I would like to be able to pause and restart their behavior tree whenever I want.
My behavior tree is started in the beginplay of an AIController but I can’t find a way to get the references of it.
I tried :

  • “Stop logic” by getting the brain component of my AIController
  • Adding a Behavior Tree component and start it ( problem → can’t acces to his blackboard and I have to be able to get the blackboard of my AI with his Actor controlled.

I don’t know, if there is any way to disable/enable my AIController or just pause my behavior tree ?

I would like to avoid putting a boolean in my tree that is checking if my Behavior should run or not ( beceause I feel like its gonna hurt the performance too much (beceause I have like maximum 30 AI running in the same time)).

From a pawn/character this should work

1 Like

Unfortunately it doesn’t work. Here’s the setup I tried with your message :

The BT attach to the AIController continue as it was never stoped…

hi
hi,try using “get ai controller”

1 Like

Still not working :

Why do you use Self? What blueprints are you on?
Abode is to be used from the pawn.

If you do it from the controller just grab the brain component

1 Like

Hi,
I was on the blueprint (parent class: controller) that was being controlled by the AIController.

I did your setup in my AIController :

Still not working, my brain component is valid but stopping the logic isn’t stopping his behavior tree…
I really feel that there is a really weird thing going on beceause all answers i’m getting tell me to the exact same thing but it just simply doesn’t work for me.

yes certainly, that doesn’t seem to be the problem.
Why use the begin play to activate the behavior?, although I don’t think it has anything to do with it

1 Like

hey,weird enough.
I duplicate your code to test and it works on my side.

1 Like

I did your setup with a new controller. For the purpose of the test I had to make a simple “Move To” task.

IT WORKED… but it doesn’t the way I wanted it to work. The reason why stopping the logic wasn’t stopping my AI to move is beceause the “Finish Execute AI” of another task was call only at the “Succes” after a “Move To” node.
Stopping the logic wasn’t stopping the “Move To” node from my task.

And now I wonder, is it possible to abort a task manually ?
I did plug the Finish Execute AI only in the Succes of a Move To node for optimization purposes, I don’t know if ending everytime my Move To isn’t gonna hurt the performances ?

stop logic automatically aborts the task.the problem is aborting task won’t stop AI movement in that task.

So you could use a workaround,which is putting a “stop movement immediately” along with the stop logic :smiley:

1 Like

It work !

Thanks to everyone who tried to help me, I can finally continue my enemy AI system

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.