RealDocs

APlayerState::OnRep_bIsInactive

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: virtualUFUNCTION

Description

Replication notification called on clients when the bIsInactive flag changes. Inactive PlayerStates are preserved in GameMode::InactivePlayerArray on disconnect so players can reconnect; this callback is the client-side notification of that transition.

Caveats & Gotchas

  • bIsInactive being true does not mean the player has permanently left — they may reconnect and this flag may flip back to false. Don't clean up data that needs to survive a reconnect inside this callback.
  • The transition to inactive happens on the server inside GameMode::AddInactivePlayer. The replication of this flag is the only notification clients receive; there is no separate delegate for player disconnect on clients.
  • If you index into GameState::PlayerArray by position, note that inactive states are moved to a separate array and may no longer appear there after this callback fires.

Signature

ENGINE_API virtual void OnRep_bIsInactive();

Return Type

void

Example

Grey out a player's scoreboard row on disconnect C++
void AMyPlayerState::OnRep_bIsInactive()
{
	Super::OnRep_bIsInactive();
	UWorld* World = GetWorld();
	if (!World) return;
	APlayerController* PC = World->GetFirstPlayerController();
	if (!PC) return;
	if (AMyHUD* HUD = Cast<AMyHUD>(PC->GetHUD()))
	{
		HUD->SetPlayerRowGreyed(this, IsInactive());
	}
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.