Hello,
I have this Behaviour Tree for an enemy AI :
At first, (Parallel Selector), the enemy wanders while checking if the player is in view. If the player attacks the enemy, or get into the enemy's view, the player will be set as the AI's target and it will proceed to the right part under the Repeater.
The AI's select a combat action (attack the player in melee with a weapon like a sword, throw a fireball etc.). Then, according to the combat action picked, it will check if the target (the player) is within range. If not, it will seek the target to make it in range to perform the action. Otherwise, it just performs the action.
When performing an action, a boolean "IsPerformingAction" is set to true, so the AI won't do anything else until the action has been performed. (The bool is set back to False at the end of the action animation or when leaving the Perform Combat Action task via its OnEnd() method).
It also triggers a global action cooldown, independent from the previous and next action, that prevents the enemy from spamming actions.
For example:
- the AI performs an action
- a cooldown is triggered (like 2s for example)
- After these 2s, the AI will be able to pick a new action and perform it. (it actually managed in the Perform Combat Action where during this cooldown, it returns TaskStatus.Running. After that cooldown has elapsed, as the AI has already performed the action, the task returns Failure and the right branch starts from the beginning).
What I want is to make the AI continuously check if the target is still within distance while it waits for the cooldown to be over.
If I set a conditional abort on the selected Selector in the screenshot to "Lower Priority", it will also abort the Perform Combat Action task when it is performing an action to seek its target. What I would like is to make the AI seek the target if it is not within distance while it waits for the cooldown to be over, not when it is performing an action (known via the boolean variable I mentioned above).
How would I do that ?
Thanks
I have this Behaviour Tree for an enemy AI :
At first, (Parallel Selector), the enemy wanders while checking if the player is in view. If the player attacks the enemy, or get into the enemy's view, the player will be set as the AI's target and it will proceed to the right part under the Repeater.
The AI's select a combat action (attack the player in melee with a weapon like a sword, throw a fireball etc.). Then, according to the combat action picked, it will check if the target (the player) is within range. If not, it will seek the target to make it in range to perform the action. Otherwise, it just performs the action.
When performing an action, a boolean "IsPerformingAction" is set to true, so the AI won't do anything else until the action has been performed. (The bool is set back to False at the end of the action animation or when leaving the Perform Combat Action task via its OnEnd() method).
It also triggers a global action cooldown, independent from the previous and next action, that prevents the enemy from spamming actions.
For example:
- the AI performs an action
- a cooldown is triggered (like 2s for example)
- After these 2s, the AI will be able to pick a new action and perform it. (it actually managed in the Perform Combat Action where during this cooldown, it returns TaskStatus.Running. After that cooldown has elapsed, as the AI has already performed the action, the task returns Failure and the right branch starts from the beginning).
What I want is to make the AI continuously check if the target is still within distance while it waits for the cooldown to be over.
If I set a conditional abort on the selected Selector in the screenshot to "Lower Priority", it will also abort the Perform Combat Action task when it is performing an action to seek its target. What I would like is to make the AI seek the target if it is not within distance while it waits for the cooldown to be over, not when it is performing an action (known via the boolean variable I mentioned above).
How would I do that ?
Thanks