Code Reference‎ > ‎


class Targetable: MonoBehaviour

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.

OnHit(HitEffectsList effects, Target target)
Triggered every time this targetable is hit. This event can originate from a TargetTracker (if triggered through scripting), a FireController or Projectile component.

HitEffectsList effects
A list of HitEffect structs which represent all the effects sent by a TargetTracker or FireController 

Target target
target struct with access to cached information going all the way back to the TargetTracker  which found this target and including any components which touched it, such as a FireController.

void AddOnHitDelegate(OnHitDelegate del)
void SetOnHitDelegate(OnHitDelegate del)
void RemoveOnHitDelegate(OnHitDelegate del)

OnHitCollider(HitEffectsList effects, Target targets, Collider other)
Exactly the same as OnHit but adds the Collider to the signature. Collider may be null if not applicable.

void AddOnHitColliderDelegate(OnHitColliderDelegate del)
void SetOnHitColliderDelegate(OnHitColliderDelegate del)
void RemoveOnHitColliderDelegate(OnHitColliderDelegate del)

OnDetected(TargetTracker source)
Triggered once when this target is first detected by a TargetTracker .

TargetTracker source
A reference back to the TargetTracker component which triggered this event

void AddOnDetectedDelegate(OnDetectedDelegate del)
void SetOnDetectedDelegate(OnDetectedDelegate del)
void RemoveOnDetectedDelegate(OnDetectedDelegate del)

OnNotDetected(TargetTracker source)

Triggered once when this target is no longer detected by a TargetTracker.

TargetTracker source
A reference back to the TargetTracker component which triggered this event

void AddOnNotDetectedDelegate(OnNotDetectedDelegate del)
void SetOnNotDetectedDelegate(OnNotDetectedDelegate del)
void RemoveOnNotDetectedDelegate(OnNotDetectedDelegate del)

Members (Other)


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.

float distToDest

Returns the distance as sqrMagnitude

Get the distance from this GameObject to the nearest waypoint and then through all remaining waypoints. Set the waypoints (List of Vector3) to use this feature. The distance is kept as a sqrMagnitude for faster performance and comparison.

float GetDistToPos

A Utility method that will return the distance from the targetable to any point in space, such as another Transform. This is great for simple min/max style calculations but for comparing two distances, use 
GetSqrDistToPos for best possible performance.

float GetSqrDistToPos

A Utility method that will return the distance from the targetable to any point in space, such as another Transform. This uses the vector square magnitude calculation which is the fastest known way to get a distance.

bool isTargetable

Turning this off effectively "hides" this Targetable from TargetPRO, meaning it won't be detected by any TargetTrackers. True by default.

public List<Perimeter> perimeters

The list of Perimeters currently detecting this Targetable. This is used internally to remove references of this Targetable from all Perimeters when deactivated/destroyed. You can get to the TargetTracker which owns this perimeter by using Perimeter.targetTracker.

float strength

The number used to sort this Target when a TargetTracker is set to MostPowerful or LeastPowerful. This can be any arbitrary number for any use. For example, set this higher on a player-selected target to make guns attack it first. Or set this to a target's life to make the TargetTracker hit the most or least healthy target. 

List<Vector3> waypoints

This is just a list of positions, which you set, that is used to determine the distance to the final destination when an applicable sorting option is used. (See distToDest.)  This is usually set by a pathing or other positioning system.

Transform xform

A cached reference to the Transform of the Targetable game object.