I have a task for my enemy - go closer to the player.
The problem is that the enemy picks a spot that is close to the player and goes to it. But the player in the meantime changes the location, for example, goes to meet the enemy. I would like to do something like … if the enemy is on the way to the player and the player approaches, shoot.
can you show what’s inside the first task?
I guess the main issue might be there.
ofc all tree screenshots will be better
edit:
I assume you didn’t plug in the player ref to the AI move node. Instead you did a extra “get actor location ” for the target location.
if that’s the case just plug in the player ref to the target directly.
if you give it target reference it will continuously chase the target until reach the acceptance radius .
Behavior tree is different than the usual blueprints. It has stricter priorities therefore it is actually not possible to execute multiple tasks at the same time. (Priorities are indicated by the numbers on each node’s corner) But if you want to have different functions working at the same time, why don’t you combine them in a single task and use sequences to achieve that objective? (I’m talking about the sequence node and not the one in the behavior tree)
As for your main objective, you can use decorators in a selector, and make the AI to move to that shooting task you mentioned if a blackboard key that’s a bool type variable changes it’s value. You can update that variable continuously in your AI controller blueprint.
You can store the player’s location by casting to your player, getting the actor location and assigning it’s location into a vector type variable. Then you can subtract that from the AI’s location, get the result’s vector length and check if it gets shorter.