RealDocs

APawn::IsLocalPlayerControllerViewingAPawn

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

Description

Returns true if this pawn is currently the ViewTarget of any local player controller, whether that player is directly controlling it or spectating it. Useful for culling expensive per-frame work on pawns that are not being watched.

Caveats & Gotchas

  • This checks local player controllers only — a pawn being watched by a remote spectator will return false, even in split-screen if no local controller is viewing it.
  • IsLocallyViewed() is the Blueprint-exposed counterpart that also considers spectating; prefer that method in Blueprints or when you need to account for in-game replays.

Signature

bool IsLocalPlayerControllerViewingAPawn() const

Return Type

bool

Example

Skip expensive VFX updates for off-screen pawns C++
void AMyPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (IsLocalPlayerControllerViewingAPawn())
	{
		UpdateExpensiveVFX(DeltaTime);
	}
}

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.