APawn::IsLocallyControlled
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualUFUNCTIONBlueprintPure
Description
Returns `true` if this pawn is controlled by a local (non-network) controller — i.e., the controller exists on the same machine executing this code.
Caveats & Gotchas
- • On a dedicated server this returns `false` for all player pawns because the PlayerController is on the client. Use `HasAuthority()` if you need a server-only check, or `IsPlayerControlled()` to detect human control regardless of locality.
- • For AI-controlled pawns on a server, this returns `true` because the AIController is local to the server — which is often unexpected when using this as a 'player input' guard.
Signature
virtual bool IsLocallyControlled() const Return Type
bool Examples
Skip first-person cosmetics on Tick for non-locally-controlled pawns
Blueprint
Skip cosmetic effects for non-local pawns C++
void AMyPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (IsLocallyControlled())
{
UpdateFirstPersonEffects(DeltaTime);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?