Table of Contents

Class NearestTargetSelector

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Selects the nearest UnityEngine.GameObject to the context within a given radius and layer mask. Useful for targeting the closest enemy, ally, or object.

[Serializable]
public class NearestTargetSelector : TargetSelector
Inheritance
NearestTargetSelector
Inherited Members

Fields

MaxHits

Starting size of the overlap buffer. Not a cap on the result.

[Tooltip("Starting size of the overlap buffer. This selector returns one target; the value only affects allocation.")]
[Min(1)]
public int MaxHits

Field Value

int

Remarks

This selector emits exactly one target — the nearest candidate — so there is nothing for a cap to truncate. The value only chooses the buffer's starting size through QueryBufferSize(int), and TryGrowQueryBuffer<T>(ref T[], int) grows past it whenever a query comes back full, so setting it low costs a reallocation in a crowd and never a lost candidate.

The tooltip said "maximum number of hits to process", which is what ChainTargetSelector's used to say for the same non-reason: a designer lowering it expects fewer victims and gets a smaller buffer.

Radius

Radius to search for targets.

[Tooltip("Radius to search for targets.")]
[Min(0)]
public float Radius

Field Value

float

TargetLayer

Layer mask to filter targets.

[Tooltip("Layer mask to filter targets.")]
public LayerMask TargetLayer

Field Value

LayerMask

Methods

SelectTargets(EventData)

Returns the nearest UnityEngine.GameObject to the context within Radius.

public override IEnumerable<GameObject> SelectTargets(EventData eventData)

Parameters

eventData EventData

The event driving the selection.

Returns

IEnumerable<GameObject>

An enumerable containing the nearest UnityEngine.GameObject, or empty if none found.