RealDocs

APawn::IsLocallyViewed

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

Description

Returns true if a local PlayerController has this pawn as its ViewTarget — whether controlling or spectating. Useful for gating expensive visual effects to only the locally visible pawn.

Caveats & Gotchas

  • A locally controlled pawn may return false if the player is using a remote camera view (e.g., a security camera or cinematic). Do not use this as a proxy for 'is this my pawn'; use IsLocallyControlled() for that.
  • Always returns false on dedicated servers. Safe to call anywhere but the result is only meaningful on clients.
  • The underlying bIsLocalViewTarget flag is updated in BecomeViewTarget/EndViewTarget, so it reflects the previous frame's state. Avoid using it in scenarios where ViewTarget changes happen the same frame as the check.

Signature

bool IsLocallyViewed() const

Return Type

bool

Example

Toggle a first-person mesh based on local view C++
void AMyPawn::BeginPlay()
{
	Super::BeginPlay();
	if (FirstPersonMesh)
	{
		FirstPersonMesh->SetVisibility(IsLocallyViewed());
	}
}

Version History

Introduced in: 5.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.