AI Decorator not aborting

I’m trying to write an AI that will patrol along a path until it sees the player, then chase after the player. I’ve got the chasing and the patrolling working in isolation, but when I throw them together they don’t actually seem to work correctly.

The NoticeCheck service shoots rays towards the player and updates a suspicion variable, which the IsSuspicious decorator tests for. I’ve thrown a Print node in there, and it does indeed return true when I need it to. However, as soon as IsSuspicious gets set to false the AI enters the patrol sequence, it never leaves, not even if IsSuspicious starts returning true again. It just loops constantly through its patrol path.

What can I do? I’ve already tried putting IsSuspicious on the patrol sequence set to test for the inverse (set to abort self) and adjusting the existing IsSuspicious node to abort both.

Hello, right now in the tree there isn’t any condition to cancel and therefore leave the patrol sequence. I think you should put a boolean decorator in the Patrol sequence with the condition Is NOT Suspicious and it should abort. I also think that the observer type should be OnResultChange.
Then, while running the patrol sequence, if the isSuspcious variable become false, the first behavior will execute.

Hope this helps.

Thanks for replying. Unfortunately, even if I have an inverted IsSuspicious decorator on the patrol sequence (set to abort self), it still doesn’t work.

Could there maybe be a problem with how I’ve implemented my IsSuspicious check?

I don’t see nothing wrong here…Where does the PlayerSuspicion come from? Are you sure this value is getting changed over the execution?

Anyways, you can try creating a boolean variable PlayerSuspicion in the blackboard and a float private variable PlayerSuspicion. Then to update the blackboard variable you will use the private float variable. Finally, in the BT you will be able to use a default boolean decorator. Try it and if it works, we must be missing something.

Weird. Switching to a Blackboard condition fixed the problem. Thanks for the solution, although now I get to figure out what I’m doing wrong (if anything) with my custom decorator…

Hum…If you find the problem tell me. I would like to know. I think it may be related with the player suspicion variable.