Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Multiple AI types workflow


I've been trying to create AI for my 2D game and I've planned to have 3-4 different versions of AI characters in my game. I've already created a simple patroling AI, but when I started to think about the remaining 3 AI character types, I've been stuck understanding the flow of the logic how I should be able to control multiple AI characters with different behavior.

I've created my first patrol AI (follows path actors) using C++ and behaviortree/blackboard. I only set the behaviortree for my character and the overall blackboard variable setup is done in the controller. Here's the controller logic:

     BB_Component = CreateDefaultSubobject<UBlackboardComponent>(TEXT("BB_Component"));
     BT_Component = CreateDefaultSubobject<UBehaviorTreeComponent>(TEXT("BT_Component"));
     AIPerception = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("PerceptionComponent"));
     SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Sense"));
     SightConfig->DetectionByAffiliation.bDetectEnemies = true;
     SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
     SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
     SightConfig->PeripheralVisionAngleDegrees = 65.f;
     SightConfig->SightRadius = 500.f;
     SightConfig->LoseSightRadius = 700.f;
 void ABasicAIController::Tick(float DeltaSeconds)
 void ABasicAIController::BeginPlay()
     AIPerception->OnPerceptionUpdated.AddDynamic(this, &ABasicAIController::SenseUpdated);
     BB_Component->SetValueAsObject(BlackBoard_Key_DesiredPathNode, Cast<ABasicAICharacter>(GetPawn())->DesiredNode);
 void ABasicAIController::Possess(APawn* InPawn) {
     ABasicAICharacter* Character = Cast<ABasicAICharacter>(InPawn);
     if (Character && Character->BehaviorTreeAsset) {
         UE_LOG(LogTemp, Warning, TEXT("POSSESSING"));
     BB_Component->SetValueAsObject(BlackBoard_Key_DesiredPathNode, Character->DesiredNode);
     BB_Component->SetValueAsObject(BlackBoard_Key_SelfActor, Character);
 void ABasicAIController::SenseUpdated(TArray<AActor*> Actors) {
     UE_LOG(LogTemp, Warning, TEXT("test"));

My question: When I want to create, for example, chasing enemies, would I have to create a new AIcontroller class for this type of enemies? It might be a dumb question, but I am not sure if I do this in right workflow nor I did not find much information how to separate the logic when creating multiple AI types (especially when using C++).

With regards

Product Version: UE 4.16
more ▼

asked Sep 19 '17 at 11:17 AM in C++ Programming

avatar image

129 7 11 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question