void APawn::PossessedBy(AController* NewController) { AController* const OldController = Controller; Controller = NewController; ForceNetUpdate(); if (Controller->PlayerState != NULL) { PlayerState = Controller->PlayerState; } if (APlayerController* PlayerController = Cast<APlayerController>(Controller)) { if (GetNetMode() != NM_Standalone) { SetReplicates(true); SetAutonomousProxy(true); } } else { CopyRemoteRoleFrom(GetDefault<APawn>()); } // dispatch Blueprint event if necessary if (OldController != NewController) { ReceivePossessed(Controller); } }
void ASpectatorPawn::PossessedBy(class AController* NewController) { if (bReplicates) { Super::PossessedBy(NewController); } else { // We don't want the automatic changing of net role in Pawn code since we don't replicate, so don't call Super. AController* const OldController = Controller; Controller = NewController; // dispatch Blueprint event if necessary if (OldController != NewController) { ReceivePossessed(Controller); } } }