bool AShooterAIController::IsDead() const
{
AShooterCharacter* ControlledCharacter = Cast<AShooterCharacter>(GetPawn());
if (ControlledCharacter != nullptr)
{
return ControlledCharacter->IsDead();
}
return true;
}
I got Pawn from here. But does this Pawn mean AI here?
void AKillEmAllGameMode::EndGame(bool bIsPlayerWinner)
{
for (AController* Controller : TActorRange<AController>(GetWorld()))
{
bool bIsWinner = Controller->IsPlayerController() == bIsPlayerWinner;
Controller->GameHasEnded(Controller->GetPawn(), bIsWinner);
}
}
I also have a question from this code, if the player loses. bIsPlayerWinner becomes false, and since the player lost, you can’t use the controller separately.
Then will the Controller->IsPlayerController() be false? The player’s controller is disconnected, so I’ll check the remaining AI controllers. (It’s ambiguous to describe it in words.)
There, false, false is the same, so bIsWinner is true. Then you get into GameHasEnded like the player won.
I don’t understand this code. I don’t know if I don’t understand… Can you explain it easily?