Hi,
I have a behavior tree on an enemy, which uses the "Patrol" task from the movement pack, along with two ConditionalEvaluator tasks, configured with HasReceivedEvent. I want the tree to start running when the enemy spawns in the scene, stop when the enemy despawns and returns to its pool, and then restart when the enemy spawns again. I haven't yet figured out how to do the last part properly. So, upon enemy respawn, the enemy remains still. Apparently, the 2nd HasReceivedEvent evaluates to true, even though it hasn't be sent a 2nd time.
Above is the tree with the enemy behaving as intended, after the initial enemy spawn. The ConditionalEvaluator task on the left is set to receive the "PlayerInjured" event, upon which, it executes the StopBehaviorTree event, with "Pause Behavior" set to true. The intent is to be able to continue the Patrol Behavior if the Player revives. The ConditionalEvaluator task on the right is set to receive the "ResetEnemy" event, upon which, it executes the StopBehaviorTree event, with "Pause Behavior" set to false, which happens on enemy despawn. The PatrolCustom task derives from the Patrol task, and the only addition is the implementation of the OnBehaviorComplete() callback. I did this in an effort to fix this, unsuccessfully nevertheless.
Above is the state of the tree after the enemy despawns.
Above is the state of the tree after the previously despawned enemy respawns. I stepped through the code and found that the HasReceivedEvent evaluates to true, i.e. as if the "ResetEnemy" event has been sent again, only it hasn't been sent a 2nd time.
I played around with several settings of the tree and the tasks, as well as tried controlling it through code, but could not figure out how to do this.
I'd really appreciate your help.
I have a behavior tree on an enemy, which uses the "Patrol" task from the movement pack, along with two ConditionalEvaluator tasks, configured with HasReceivedEvent. I want the tree to start running when the enemy spawns in the scene, stop when the enemy despawns and returns to its pool, and then restart when the enemy spawns again. I haven't yet figured out how to do the last part properly. So, upon enemy respawn, the enemy remains still. Apparently, the 2nd HasReceivedEvent evaluates to true, even though it hasn't be sent a 2nd time.
Above is the tree with the enemy behaving as intended, after the initial enemy spawn. The ConditionalEvaluator task on the left is set to receive the "PlayerInjured" event, upon which, it executes the StopBehaviorTree event, with "Pause Behavior" set to true. The intent is to be able to continue the Patrol Behavior if the Player revives. The ConditionalEvaluator task on the right is set to receive the "ResetEnemy" event, upon which, it executes the StopBehaviorTree event, with "Pause Behavior" set to false, which happens on enemy despawn. The PatrolCustom task derives from the Patrol task, and the only addition is the implementation of the OnBehaviorComplete() callback. I did this in an effort to fix this, unsuccessfully nevertheless.
Above is the state of the tree after the enemy despawns.
Above is the state of the tree after the previously despawned enemy respawns. I stepped through the code and found that the HasReceivedEvent evaluates to true, i.e. as if the "ResetEnemy" event has been sent again, only it hasn't been sent a 2nd time.
I played around with several settings of the tree and the tasks, as well as tried controlling it through code, but could not figure out how to do this.
I'd really appreciate your help.