Hi - Currently having an issue with my Enemy AI that won’t stop shooting once it starts.
It seems that the issue isn’t on the Behavior Tree, but on the normal Enemy Blueprint I have set up.
For context, I have the Behavior Tree set up to an attack task IF the AI can see the player (set to a boolean variable CanSeePlyaer), the task then casts to my BP_Enemy and triggers the AttackTarget CustomEvent, which then flows from the below screenshots.
From what I have tested, once the AI spots the player, it will keep shooting while CanSeePlayer is true, which will print “AT Event Triggered” to the viewport every shot. Once the player breaks line of sight, “AT Event Triggered” stops printing to the viewport but the AI keeps shooting.
I do have a Blackboard Decorator for the Attack Task that checks for CanSeePlayer to be Is Set, which will Abort the task and trigger the “Stop Attacking” custom Event. That does not appear to be triggering as the “Stop Attacking Triggered” won’t print to the viewport.
I’ve spent a while on this, I’m not sure what it is but adding a Flow Control Node doesn’t appear to be fixing it and neither does updating some of the variables.
Hoping for any suggestions on what I can change or possibly a better way to implement this.
Fair enough - this is the section of the BehaviorTree in question.
It’s cycling through a Selector - functionality is:
Investigation Sequence: If the AI hears the player (sets IsInvestigating to True), set the TargetLocationVector to the location the sound came from, wait 1 second, Move To to that location
Alert Sequence: If IsInvestigating is set, run a Selector that starts with the AttackSequence which triggers is AI CanSeePlayer is set, otherwise run a LastKnownLocation sequence (not relevant at the moment).
During the AttackSequence, wait 0.1 second, Focus on the target, wait, then start the BTTask_Attack.
I might need to record the gameplay because when I look at the BehaviorTree while playing, the AI successfully exists the Attack task. It looks like the issue lies with the blueprint for shooting as it appears to trigger, but won’t stop once triggered, despite having the BT set to abort the Attack task when the AI can no longer see the player.