Code Reference‎ > ‎

Target Struct

struct Target

The Target struct is at the core of TargetPRO. It carries cached information about a target and the entire chain of source components which touched it.

A Target is generally obtained from an event delegate or by accessing one of the TargetPRO component's target lists.

If you need to construct a Target, there are several overloads provided. Note you need to use the 'new' keyword

target = new Target(Transform transform, TargetTracker targetTracker);
target = new Target(Targetable targetable, TargetTracker targetTracker);
target = new Target(target);

When a transform is passed a GetComponent call is used to get the Targetable, so the transform must be from a GameObject that has a Targetable component.

Using the second two have almost no performance overhead because they simply pass off references. No component look-ups occur.

Target Cache Members
These members are references to components which are on your target GameObject.
  • public GameObject gameObject
  • public Transform transform
  • public Targetable targetable

Source Cache Members
These members are references to TargetPRO components which have come in contact with this Target. These will be null if the component was not used or never touched the Target struct (except targetTracker, which will always be available as it is the ultimate source of all targets.)
  • public TargetTracker targetTracker
  • public FireController fireController
  • public Projectile projectile

Testing for 'null'

Since struct references can't be null, a static "null" member is available to test against.

  • public static Target Null


if (target == Target.Null)
    // Do something