RealDocs

UGameplayStatics::IsAnyLocalPlayerCameraWithinRange

function Engine Blueprint Since 4.0
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticBlueprintPureBlueprintCosmetic

Description

Returns true if any local player's camera is within MaximumRange of the specified world location. Designed as a cheap cosmetic cull gate for effects that only matter when a player is nearby.

Caveats & Gotchas

  • BlueprintCosmetic: always returns false on dedicated servers. Never use this to make authoritative gameplay decisions — it is purely a client-side cosmetic check.
  • Measures distance from the camera location (view origin), not from the player pawn. A player spectating from a distance will pass this check at a different range than their pawn would.
  • For split-screen games, returns true as soon as any one local camera is in range — you cannot distinguish which player triggered the check.

Signature

static ENGINE_API bool IsAnyLocalPlayerCameraWithinRange(const UObject* WorldContextObject, const FVector& Location, float MaximumRange);

Parameters

Name Type Description Default
WorldContextObject const UObject* Object used to retrieve the world context.
Location const FVector& World-space location to test against.
MaximumRange float Maximum distance (in Unreal Units) from Location within which any local camera must fall.

Return Type

bool

Example

Skip spawning a particle system when no player is nearby C++
if (UGameplayStatics::IsAnyLocalPlayerCameraWithinRange(this, GetActorLocation(), 2000.f))
{
    UNiagaraFunctionLibrary::SpawnSystemAtLocation(
        this, AmbientFX, GetActorLocation());
}

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.