APawn::IsPlayerControlled
#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
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
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?