I am trying to figure out how to create a simple and functional behavior ai tree. That when the ai shoots at the player at a random time ranges when it’s far away from the player. I’m trying to create a selector for the playerisinranged bool but not sure where to go from here. Any help is appreciated.
There are multiple ways you could do it.
You could set the blackboard values through the AI controller class or set the variable as instance editable inside the behaviour tree task class.
Another thing that you should pay attention to is setting the selected tree node decorator to be self, so it can be interrupted whenever the blackboard decorator value changes.
when the ai sees the player with different tasks, decorators and selectors, one running task can quickly overlap to the next depending on the key selector? Or am I wrong? Also will a pawn sensing on the ai blueprint can help and/or be referenced in the tree tasks to detect whether the player is in or out the collider?
What do you mean by,
one running task can quickly overlap to the next depending on the key selector?
I’m guessing you are talking about task interruption? If so, then yes, if you set observe aborts to “self”, it will interrupt the currently running task and execute the task with the satisfied decorator condition.
If your pawn sensing is setting the decorator blackboard values, then yes, it will trigger the interrupt. Say, if the AI “do not see the player” task is running currently, and soon the pawn sensing (in the AI controller class) triggers the sight, and you can set the blackboard value via the AI controller to change the respective blackboard value (in this case a simple boolean tick should be enough). This will trigger the interrupt inside your running task and execute whichever the task that the blackboard value satisfied.