Download

Reducing casting in Behavior tree tasks

Hey. Having a little trouble with the behavior tree and task’s

Is there any way to Set and use a reference to a AI controller in a blackboard?

The videos ive been watching behavior trees have each task if needed casting to the Ai controller to call an event or whatever else controller side.
i just want to know if there is a way i can avoid the cast every time the task is executed.

Also what would be the best way to execute animations from the behavior tree?
for the example of idle animations:

say the behavior tree executes moveto, wait, pick/execute idle animation - repeat

would i:

as the pawn play anim/ or montage
or do something involving the animation blueprint?

should i only be using the animation blueprint for locomotion? where is the line?

My philosophy is that if you call it once in a while, use the AIController. If you need to update continuously, use BT.

For example, you can the AI to see the player, you use the AI controller to update the Blackboard key. However, if you need constant updates on the player location, you would take that blackboard key, and get the location every BT run, via a Service.

For animations, I create a custom events that plays a montage in the AI Character that does exactly what I need it to do, and have the BT call that custom event when you need it. I like to use isMontagePlaying so it will complete the animation.