How set my AIs behavior depending on what it is investigating?

Hello. I am new to making AI and currently trying to make a stealth game. I have made a datatable of different things an AI might hear or see (Perceptibles) so that I can easily adjust their relative priority and other data.

My goal is a system where I can set in each type of NPC some type of subtree for each different type of perceptible in the PerceptibleType Enum, allowing me to do something like an interface(?) sort of deal where I have the “functions”(Like a broken window event) then I put the “implementation”(Like the investigate room tree) in for the npc type. So when a Guard NPC detects a broken window, it runs the investigate room tree, but a Civilian NPC might run the Run Away tree.

However, I cannot find a way to add a switch on Enum sort of node which may allow me to set a behavior for each of my Perceptible types when a perceptible is set, and my only other idea is to try and make a task that the Investigate sequence calls which gets the NPCs desired sub tree for the current Perceptible type from the NPCs controller through a GetTreeForPerceptible function which I would override for each NPC, which the investigate sequence would then run. However, this seems too convoluted to be the way I’m supposed to do this.

So what would be a good way to set my NPCs behavior depending on what it is investigating?


Behavior tree

Datatable of Perceptibles

A single perceptible

Hey @Beefjerkyzxz!

What about something like this?


Then on the task, you GET the value from the blackboard (Set an Enum as public and then set it in the task based on the Blackboard- and the blackboard enum was set on “Possess” or “BeginPlay”.

Then in the task you can do a Switch on Enum!

Hope that helps!

Oh thats smart, I’ll give that a try. thank you!