Friendly / Non friendly creature Ai Workflow Questions

Hey, Im having a hard time Wrapping my head around communicating information from Instances of Enemies to Behavior trees. and im also having a hard time figuring out
an efficient system for making a bunch of different enemies.

At the end of the day i need to make a 30 or so creatures that can be friendly or Feral. and have a bunch of other either shared or specific variables to that character.

In searching around, classes came up and im pretty foggy on the subject, usually with casting i can get by okay but its a lot of fiddling because i dont 100% understand when to use what.
(PawnOwner, Player Controller, etc.)
Rescources i have found on Ai and enemies have only dealt with one character using its own simple behavior tree so Im curious of conventions i should implement in doing this over a bunch of characters.
and just to clarify im not set on using just one behavior tree for everything and everyone. just sharing one for the most basic of AI actions.

  • Would the solution be having all of the NPCs in the same class and casting to that class in the AI Controller?
  • From that cast how would I get particular variables from particular class members?
  • Do i need to make a chain checking if the Instance of the creature is Vaild?

So as is the plan is ( All PC pawns -> Ai Controller -> Behavior tree )

I tried:

NPC (Begin Play) Cast to AI_Controller -> Set Friendly?

AI_Controller (Begin Play) Run Behavior Tree -> (Blackboard) Set Value as Bool(Friendly?)

But Unreal got angry. it gave me an error because it wasnt reading it properly.

I was planning on keeping the information im trying to pass on as booleans representing states or sometimes behaviors ie. Is friendly? will attack on sight?
But i also have a RNG during idle roaming deciding whether to pick a new location or play an idle animation which are represented by
an integer value.

Im sorry if this is a little confusing - This question is the byproduct of mass confusion lol

*** EDIT ***

I tried setting blackboard values from the NPC and skipped the AI controller and it worked so thats where im at now

Hi. For my own project I made different classes for different types of enemies (Enemy_melee, Enemy_ranged, Enemy_nonhuman) deriving from common enemy_base class, each of them has their own AiController class (so separate ai_melee, ai_ranged and ai_nonhuman), behavior trees and blackboards. Friend-or-foe behavior is handled in the controller (I’m using ai perception component in the controller, so all “detection” is done there), by checking TeamID variable of the detected actor - if it’s the same, then do nothing, if not - send an “attack” signal to blackboard (in my case it is Blackboard - Set Value as Enum (KeyName=“GuardState”, Enum=“Attack”) and then behavior tree get’s it from here and continues within itself.