Code Reference‎ > ‎


class TargetTracker : MonoBehaviour

TargetTrackers and Perimeters
This TargetTracker component gives access to the Perimeter component...

  1. The Perimeter, which is the core of TargetPro and manages the primary means in which targets are detected and generates Target structs (you will become familiar with these special objects which carry all the cached information needed to work with the targets). The Perimeter holds all targets in range and grants access to this information via a special list class. For example, TargetTracker.perimeter.Count() will return the number of targets in range.

  2. The Target Tracker component provides access to the internal Perimeter, sorts the data and processes the user  input to retrieve just the right list of targets.

Members (Delegates)
The following functions are used to add, set (replace) or remove a delegate for an event. The function being passed as 'del' need only match the signature of the delegate as shown. The function name can be anything you want.

OnPostSort(TargetList targets)
Runs just before the target list is returned allowing for any custom modifications. The TargetList is passed by reference so no return value is needed. Just modify the list.

void AddPostSortDelegate(OnPostSortDelegate del)
void SetPostSortDelegate(OnPostSortDelegate del)
void RemovePostSortDelegate(OnPostSortDelegate del)

Class Members


Set to get more feedback  about what is happening in this TargetTracker and perimeter. This includes message logging as well as gizmo lines if applicable. See the TargetPRO namespace for enum options.

bool drawGizmo

Turn the editor-only display gizmo on or off

int numberOfTargets

The number of targets to return. Set to -1 to return all targets

Color gizmoColor

The color of the gizmo displayed in the Unity Editor (does not render)

Perimeter perimeter

Access to the perimeter component/list. This is rarely needed, if ever, but can be handy if you need direct access to the full list of items via perimeter.targets (which is not  the same TargetTracker's target list, which is affects by the options used). This might be useful to get access to the runtime-generated perimeter gameObject, but again, we don't think this is ever needed but is included for completeness. The TargetTracker controls the perimeter for you.


The shape of the perimeter used to detect targets in range

enum PERIMETER_SHAPES options include:
  • Capsule
  • Boxe
  • Spheree

Vector3 perimeterPositionOffset

An optional position offset for the perimeter.  For example, if you have an object resting on the ground which has a range of 4, a position offset of Vector3(0, 4, 0) will place your perimeter so it is  also sitting on the ground

Vector3 perimeterRotationOffset

An optional rotational offset for the perimeter.

int perimeterLayer

The layer to put the perimeter in when it is generated at run-time. 0 is the default layer.

Vector3 range

The range in which targets will be found. The size from the center to the edge of the perimeter in x, y and z for any shape. Depending on the shape some values may be ignored. E.g. Spheres only use X for radius

float sortInterval

How often, in seconds, the target list will be sorted. If set to 0, sorting will only update when targets enter or exit range.


The style of sorting for the perimeter to use

enum SORTING_STYLES options include:
  • None - Also good for area-of-effects where no sort is needed
  • Nearest - Closest to the perimter's center (localPostion)
  • Farthest - Farthest from the perimter's center (localPostion)
  • NearestToDestination - Nearest to a destination along waypoints
  • FarthestFromDestination - Farthest from a destination along waypoints
  • MostPowerful - Most powerful based on a iTargetable parameter
  • LeastPowerful - Least powerful based on a iTargetable parameter

LayerMask targetLayers

The layers in which the perimeter is allowed to find targets.

TargetList targets

A list of sorted targets. The contents depend on numberOfTargets requested (-1 for all targets in the perimeter), and the sorting style used.