I’m trying to use behavior tree to have my AI chase the player and once they’re within attack range stop chasing and attack them. I can’t seam to wrap my head around getting the selector checks right. Below is what I have so far.
The state service is just checking if the player is dead and that works fine. Is there a better way to do this? I was originally just using a Timer on the AI and doing a line trace based off attack frequency, but I really don’t want to do a line trace constantly if the AI isn’t anywhere near the player. It also seams weird setting blackboard values from AI BP when they should really be set from a service.
I want the AI to move to the minimum attack range and not move until the player is outside the maximum attack range for example. I can’t seam to figure out how to do this because I can’t set the acceptance radius of the MoveTo task dynamically.
I also can’t seam to figure out how to make the behavior tree wait for my attack BP event to finish before it moves on. So I can play an attack animation for example and it won’t move on until that animation is done.
I use a generic service that tells me the distance between two actors, (so I can use it for more things). To know if you have to stop I use the distance blackboard.
I saw your topic late yesterday lol! I am absolutely going to give that a try as looks like it’d solve my issue. Do you mind showing the blackboard condition back to movement?
Ah, I see. Thank you! So that won’t abort moving if for example the player moves into combat range? I though to do that it required an abort condition.
Awesome, this worked perfectly. To solve my MoveTo issue I made my own task that calls the AIMoveTo and set the acceptance radius to a blackboard key value which is set from BP when the AI spawns. This gives me my movement range, attack range, and attack frequency behavior from BP to BehaviorTree as fully functional. It then just calls my AIs attack event to do a linecast for a hit and applydamage.
I don’t need the attack recovery wait check in the behavior tree at all as I can have my attack cooldown (which is now really just the animation) directly in the attack event and it will wait until that event is done before resuming movement.
To resume the behavior tree once the attack is done I just send it a message.