Code Reference‎ > ‎

FireController

class FireControllerMonoBehaviour

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.

OnStart()
Triggered once, when when the targeting system starts up. This happens OnEnable(), which includes instanciation/spawning this component.

void AddOnStartDelegate(OnStartDelegate del)
void SetOnStartDelegate(OnStartDelegate del)
void RemoveOnStartDelegate(OnStartDelegate del)

OnUpdate()
Triggered each frame while the targeting system is active, no matter what.

void AddOnUpdateDelegate(OnUpdateDelegate del)
void SetOnUpdateDelegate(OnUpdateDelegate del)
void RemoveOnUpdateDelegate(OnUpdateDelegate del)

OnTargetUpdate(List<Target> targets)

Triggered each frame while tracking a target. Supplies a list of targets; which / how many targets are provided, depends on the settings used.

List<Target> targets
A list of target structs full of useful cached information

void AddOnTargetUpdateDelegate(OnTargetUpdateDelegate del)
void SetOnTargetUpdateDelegate(OnTargetUpdateDelegate del)
void RemoveOnTargetUpdateDelegate(OnTargetUpdateDelegate del)


OnIdleUpdate
()

Triggered each frame when there is no target in range.

void AddOnIdleUpdateDelegate(OnIdleUpdateDelegate del)
void SetOnIdleUpdateDelegate(OnIdleUpdateDelegate del)
void RemoveOnIdleUpdateDelegate(OnIdleUpdateDelegate del)


OnFire
(List<Target> targets)

Triggered each frame while tracking a target. Supplies a list of targets; which / how many targets are provided, depends on the settings used.

List<Target> targets
A list of target struct full of useful cached information

void AddOnFireDelegate(OnFireDelegate del)
void SetOnFireDelegate(OnFireDelegate del)
void RemoveOnFireDelegate(OnFireDelegate del)


OnStop
()

Triggered each frame while tracking a target. Supplies a list of targets; which / how many targets are provided, depends on the settings used.

void AddOnStopDelegate(OnStopDelegate del)
void SetOnStopDelegate(OnStopDelegate del)
void RemoveOnStopDelegate(OnStopDelegate del)


Members (Other)

float interval

The minimum interval in seconds between firing.


float fireIntervalCounter

The current counter used for firing. Gets reset when successfully fired, otherwise will continue counting down in to negative numbers. If below 0, this FireController will fire immediately when the conditions determined by the rest of the options are met.


bool fireImmediately(bool resetFireController)

Can be run to trigger this FireController to fire immediately regardless of counter or other settings. This still executes any PreFireDelegates


bool initIntervalCountdownAtZero

When true, this controller will fire immediately when it first finds a target, then continue to count the interval normally. When false, the countdown will start counting when it first finds a target.


NOTIFY_TARGET_OPTIONS detonationMode

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

enum DETONATION_MODES options include:
  • Off Do not notify targets. delegates can still be used for custom handling
  • Direct Targets will be notified directly of this controllers effects OnFire. For example, if the ammo is just an instance effect, such as lightening, use this so the ammo doesn't need to handle anything.
  • PassToProjectile OnFire, a projectile will be launched and passed this controllers effects. The projectile must then handle notification.  For example, if you want the weapon to determine the effects of the ammo, use this.
  • UseProjectileEffects OnFire, a projectile will be launched but this controllers effects will NOT be passed. The projectile's effects will be used instead. The projectile must then handle notification. For example, if you want the ammo to determine the effects,use this.

Transform ammoPrefab

An optional prefab to instantiate, for each target, each OnFire event. If you have PoolManager installed, you can set TargetPRO to automatically pool projectiles. See the TargetPRO namespace documentation for more.


list<HitEffectList> effectsOnTarget

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

bool waitForAlignment

If true, wait for the target to be in front of the FireController emitter (see below) before firing.


float lockOnAngleTolerance

If waitForAlignment is true, and the target is within this angle, in degrees, the target can be fired upon.


bool flatAngleCompare

If true, only the general direction matters. (Good when turning in a direction but perfect alignment isn't needed.)  If false, the true angles will be compared for alignment (More precise. Emitter must point at target.) 


Transform emitter

If waitForAlignment is true: This transform is used as the point to fire from. Use this when you want a projectile to be instanced at a different place than the center of the FIreController's GameObject. For example, the tip of the barrel of a gun, or the basket of a catapult.
Optional. Default is this FireController's Transform


DEBUG_LEVELS debugLevel

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.


Transform xform

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