i have a behavior tree running for my horse, now i setup in the behavior tree to chase a target if target is set, and to attack it if in attack range, now i have an issue where the behavior tree is stuck at attacking the moment the target is set, even if its not in range it just stuck at attack when i changed the aborts to “both” for “TargetIsSet” and “DistanceToTarget”. i played with the aborts and sometimes the horse chases the target first, but when it reaches it, it starts attacking but stays stuck at it even if the target leaves the range. how to fix this issue, iam not that experienced in behavior trees.
Hey!
Generally speaking you should always use the GameplayDebugger to check the state of your AI and its BT Tasks.
Also just a hint to avoid weird issues like yours, in your Event Receive Execute AI function of your BT Task, make sure to also call Finish Execute when your cast node fails (but return Success = false)
Setting your blackboard conditions (TargetActor is set and Distance Check) to abort both itself and lower priority tasks is good as well.
For further help, could you verify if it actually is the BTTask_HorseAttack that seems to be stuck?
Also does it just execute over and over again or is it stuck in just one execution and never finishes (check what I said above) ?
so what actually happens is it keeps executing over and over again in the behavior tree. and not the attack task itself, and incase i added the finishes execute = false for cast failed node. but still same issue, so its the behavior tree casting the attack none stop
okay so i fixed it, my problem was i wasnt actually assigning it in the behavior tree. i didnt set them to editable so i can change it. its crazy how i wasted 3 hours trying multiple stuff while the issue was simple XD. thank you for opening my eyes to look at simple stuff <3
there is another thing bugging me, i have in the enemies a boolean for “is dead” but how do i actually make the horse see that the enemy “is dead” without having it to wait until the actor is destroyed.
Well the way how you would implement something like this depends a lot on your skills in ue.
Usually what games would do is implement a custom sight affiliation filter that makes the enemy “visible” to the ai only under certain conditions (aka being alive, etc).
I assume (non-personal) that, since you said you’re pretty new to BTs, you would prefer a simpler solution .
Also I would need to know more about how your AI logic is currently setup .
Either way, I would recommend you to check whether your enemy is alive every time your AI “sees” a new target and add another service in your BT that checks if the enemy is dead and then clears your TargetEnemy key.
Its not ideal but by far the most simple way.