I’m writing a component of my AI manager which needs to keep track of two things for every actor participating in a dynamic cutscene: what “phase” (arbitrary measure) of the cutscene they’re in, measured by an int, and which behavior tree(s) hold the desired AI logic for them to perform. The idea is that every time the stage of a cutscene changes, every participating actor checks the behavior tree they’re in against the behavior tree they’re supposed to be in, updating if needed. My first attempt did this with a struct, which works pretty well:
USTRUCT()
struct FSmartZoneRoleStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
FString RoleName;
UPROPERTY()
Int currentPhase;
UPROPERTY()
AActor* roleActor; //This is the actor whose AIController we'll give trees from behaviorList to
UPROPERTY(EditAnywhere)
TArray<UBehaviorTree*> behaviorList;
void Destroy() //For GC
{
RoleName = NULL;
behaviorList.Empty();
roleActor = nullptr;
}
};
With this, all I need to do is check if roleActor’s AIController’s BehaviorTree == behaviorList[currentPhase], and if it doesn’t, change it. The problem I’m having is that I would like to add more than one behavior tree to a single phase, and let the actor pick one of the trees at random when it updates itself. This lets me do things like simulate a concert audience, by putting CheerBT, MoshBT, and HeadbangBT behavior trees in the FSmartZoneRoleStruct spectator’s behaviorList[1], and trusting that approximately one third of the crowd will end up doing each of the three desired behaviors.
This is where I’m running into trouble- I tried making my behaviorList a TMap<int, TArray<UBehaviorTree*>, but the compiler said that ue doesn’t like nested data containers- is there another obvious way to accomplish this?