Playertargetindicator
Based on game build 714014 | Last updated: 2026-03-03
Overview
PlayerTargetIndicator is a client-side component that manages the visibility of target indicators for other players. It monitors which players are currently within the camera frustum, ensures they meet tracking criteria (via hudindicatable), and updates the HUD accordingly by adding or removing target indicators. The component relies on the hudindicatable and hudindicatablemanager components to determine tracking eligibility and discovery of eligible targets.
Usage example
local inst = CreateEntity()
inst:AddComponent("playertargetindicator")
-- The component automatically registers for events and starts tracking when the entity is updated
-- Typically added to player prefabs to manage their view of other players' target indicators
Dependencies & tags
Components used:
hudindicatable(viatarget.components.hudindicatable:ShouldTrack())hudindicatablemanager(viaTheWorld.components.hudindicatablemanager.items)
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
offScreenPlayers | table (array) | {} | List of players currently off-screen but whose indicators are visible (tracked for removal when they return on screen or become untrackable). |
onScreenPlayersLastTick | table (array) | {} | List of players who were within camera frustum in the previous update frame. |
Main functions
ShouldShowIndicator(target)
- Description: Determines whether the target player should have a target indicator added to the HUD. Returns
trueonly if the target is eligible for tracking and was on-screen in the previous frame (indicating it just moved off-screen). - Parameters:
target(Entity) — the potential target player entity. - Returns:
boolean—trueif the indicator should be shown, otherwisefalse. - Error states: Assumes
target.components.hudindicatableexists; may fail if called on an entity without this component.
ShouldRemoveIndicator(target)
- Description: Determines whether an existing target indicator should be removed. Returns
trueif the target no longer qualifies for tracking. - Parameters:
target(Entity) — the target player entity currently shown. - Returns:
boolean—trueif the indicator should be removed, otherwisefalse.
OnUpdate()
- Description: The main update loop. Checks tracked off-screen players for removal conditions, identifies newly eligible targets via the world’s
hudindicatablemanager, and updates HUD indicators. Also refreshesonScreenPlayersLastTickfor next-frame comparison. - Parameters: None.
- Returns: Nothing.
- Error states: Relies on
TheWorld.components.hudindicatablemanagerbeing present; silently skips updates if missing.
OnRemoveFromEntity()
- Description: Cleanup function called when the component is removed. Removes all currently tracked target indicators and deregisters event callbacks.
- Parameters: None.
- Returns: Nothing.
Events & listeners
- Listens to:
unregister_hudindicatable— triggersOnPlayerExitedto remove target indicators when a player leaves the world or is unregistered. - Pushes: None.