APlayerState::IsOnlyASpectator
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns true if this player can only ever be a spectator and is permanently barred from entering the game as a playing participant.
Caveats & Gotchas
- • This is distinct from IsSpectator() — IsSpectator returns true when the player is currently spectating (temporarily), while IsOnlyASpectator means the player was never allowed to play at all (e.g. a dedicated spectator slot).
- • bOnlySpectator is a replicated flag set by the game mode at login time. Changing it after the fact on the server does not automatically move the player into or out of spectator state — you must also handle the controller/pawn side manually.
Signature
bool IsOnlyASpectator() const
{
return bOnlySpectator;
} Return Type
bool Example
Gate gameplay features for spectators C++
bool AMyGameMode::CanPlayerPickupItem(APlayerState* PS) const
{
if (!PS || PS->IsOnlyASpectator())
{
return false;
}
return true;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?