APawn::IsLocallyControlled
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualconst
Description
Returns true if this pawn is controlled by the local player on this machine. Used to gate client-side-only logic like camera setup or local input feedback.
Signature
virtual bool IsLocallyControlled() const Return Type
bool Caveats & Gotchas
- • In a listen server game, the host player's pawn returns true for both HasAuthority() and IsLocallyControlled(). Other clients have pawns where only IsLocallyControlled() is true.
- • AI-controlled pawns always return false.
Example
Gating local-player-only code C++
void AMyPawn::BeginPlay()
{
Super::BeginPlay();
if (IsLocallyControlled())
{
// Only set up camera for the local player
SetupCamera();
}
} See Also
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?