RealDocs

APawn::IsPlayerControlled

function Engine Blueprint Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualUFUNCTIONBlueprintPure

Description

Returns true if this Pawn is controlled by a human player (possessed by a PlayerController). Unlike IsLocallyControlled, this also returns true for pawns controlled by remote clients on the server.

Caveats & Gotchas

  • Returns true for remotely controlled player pawns on the server — it checks for a PlayerController, not a local one. Use IsLocallyControlled() if you need to know whether the controlling player is on this machine.
  • Returns false for AI-controlled pawns even if an AIController is present. Use IsBotControlled() for the complementary check.
  • If the pawn has no controller at all (e.g. just spawned, not yet possessed), this returns false even though it is neither player- nor bot-controlled.

Signature

ENGINE_API virtual bool IsPlayerControlled() const;

Return Type

bool

Examples

Activate player HUD on BeginPlay only when controlled by a human player Blueprint
Event BeginPlay Branch Condition Condition True False Print String In String Player HUD activated Player HUD activated Is Player Controlled Target is Pawn Return Value
Edit Blueprint graph Activate player HUD on BeginPlay only when controlled by a human player
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Branch logic by controller type C++
void AMyPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (IsPlayerControlled())
	{
		// Show player-specific HUD elements, play footstep sounds, etc.
	}
	else if (IsBotControlled())
	{
		// Run AI-specific per-frame logic
	}
}

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.