could someone help me? i’m supposed to have a winning and losing system and its a KillEmAllGameMode but when a pawn is killed i cast it to a PlayerController and if its not null ptr then the player loses?? I simply don’t understand why this happens.
void AKillThemAllGameMode::PawnKilled(APawn *PawnKilled)
{
Super::PawnKilled(PawnKilled);
APlayerController *PlayerController = Cast<APlayerController>(PawnKilled->GetController());
if (PlayerController)
{
EndGame(false);
}
}
void AKillThemAllGameMode::EndGame(bool bIsPlayerWinner)
{
for (AController *Controller : TActorRange<AController>(GetWorld()))
{
bool bIsWinner = Controller->IsPlayerController() == bIsPlayerWinner;
Controller->GameHasEnded(Controller->GetPawn(), bIsWinner);
}
}