Code Reference‎ > ‎


class ProjectileTargetTracker

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.

Runs when this projectile is launched

void AddOnLaunchedDelegate(OnLaunchedDelegate del)
void SetOnLaunchedDelegate(OnLaunchedDelegate del)
void RemoveOnLaunchedDelegate(OnLaunchedDelegate del)

Runs every frame

void AddOnLaunchedUpdateDelegate(OnLaunchedUpdateDelegate del)
void SetOnLaunchedUpdateDelegate(OnLaunchedUpdateDelegate del)
void RemoveOnLaunchedUpdateDelegate(OnLaunchedUpdateDelegate del)

OnDetonationDelegate(TargetList targets)
Runs when this projectile detonates. Depending on the options used, this can happen when a target is hit, when the timer expires, or when the rigid body goes to sleep (comes to rest).

void AddOnDetonationDelegate(OnDetonationDelegate del)
void SetOnDetonationOnStartDelegate(OnDetonationDelegate del)
void RemoveOnDetonationDelegate(OnDetonationDelegate del)

TargetTrackers and Perimeters

Projectiles, like TargetTrackers give access to the Perimeter component, though you will rarely need to access it directly. Here is a little more information should it be needed...
  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, Projectile.perimeter.Count() will return the number of targets in range.

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

Class Members

Target target

Holds the target passed by the FireController on launch.

list<HitEffectList> effectsOnTarget

A list of HitEffect structs which can be used to determine how this FireController can affect a target.

bool notifyTargets

If false delegates will sill be triggered but targets will not be automatically notified of the effectsOnTarget

bool areaHit

If true, more than just the primary target will be affected when this projectile detonates. Use the range options to determine the area where targets can be effects.

bool detonateOnRigidBodySleep

If the projectile has a rigidbody, this will detonate it if it falls asleep. See Unity's docs for more information on how this happens.


Determines what should cause this projectile to detonate, in regards to targets.

enum DETONATION_MODES options include:
  • targetOnly Only a direct hit will trigger detonation.
  • hitLayers Contact with any colliders in any of the layers in the HitLayers mask will trigger detonation.

Class Members (Inherited from TargetTracker)


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

Color gizmoColor

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

int numberOfTargets

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

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 userd.

Transform xform

A cached reference to the Transform of this component's GameObject.