Do the enemies share a collective hivemind?

After finishing the Simple Shooter section and setting some ShooterCharacter instances around the map I realized that they share knowledge about the player location so if one of them sees you all of them do and go to the last known position, no matter how far they are. Is this intended?

Because I guess it’s out of the scope of the course but modifying the AI behavior could be another bullet point to the mega challenge. Thanks @sampattuzzi for this section and the new UE5 course!

That shouldn’t happen, no. If you go to the blackboard keys, is this checked?
image

1 Like

No, it’s not. I checked again and they only seem to share knowledge of the player position the first time one of the AIControllers sees the player. All of the others come to investigate at the same spot. After that they behave as expected of individuals.

Oh, wait a minute… I thought there could be something wrong in my version of AShooterAIController::BeginPlay() and sure there is:

void AShooterAIController::BeginPlay()
{
	Super::BeginPlay();

	/*Uh, oh1*/APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
	//SetFocus(PlayerPawn, EAIFocusPriority::Default);
	if (AIBehavior != nullptr) {
		RunBehaviorTree(AIBehavior);

		/*Uh, oh2*/GetBlackboardComponent()->SetValueAsVector(TEXT("PlayerLocation"), PlayerPawn->GetActorLocation());
		GetBlackboardComponent()->SetValueAsVector(TEXT("StartLocation"), GetPawn()->GetActorLocation());
		/*Uh, oh3*/GetBlackboardComponent()->SetValueAsVector(TEXT("LastKnownPlayerLocation"), PlayerPawn->GetActorLocation());**
	}
}

I was setting up the player location at BeginPlay! Commenting out the /*uh, oh*/ lines and recompiling fixed this. I probably missed the part where Sam removes this code from ShooterAIController, my bad.

@DanM Thanks for pointing me on the right direction, though. I didn’t know about that checkbox, and this kind of behaviour would be actually alright for a stealth game, so I learned something new from this. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms