Documentation‎ > ‎

5. Projectile

When this component is added to a game object it can be added to a FireController to be automatically spawned. When instantiated by a  FireController, it is initialized with a target and other information based on the  FireController settings.

The Projectile class inherits from TargetTracker, and has members similar to a  FireController, so that it can respond to targets by triggering events. It is designed to work like a  FireController but as a one-time event, instead of firing repeatedly. For example, it can be used to create a missile that triggers an explosion and notifies all targets in range. It can also optionally detonate after a fixed amount of time and/or when a rigid body comes to rest.

This section will familiarize you with the Editor interface and options so you can get started right away. More detail on how this system is implemented is provided in the Projectile Code Reference section

Hit Layers
Only targets on these layers will be used. You can choose as many as you wish.

Detonation Mode
  • Target Only - Only directly hitting a target will trigger detonation.
  • Hit Layers -  Contact with any colliders in any of the layers in the Hit Layers mask  will trigger detonation.
An optional timer to detonate the projectile. The timer will begin counting down on Instantiation. This can be used in conjunction with all other options.

Detonate On Sleep
If on, and the rigid body goes to sleep (comes to a rest). The projectile will detonate. This can be used in conjunction with all other options.

Area Hit
If true, more than just the primary target will be affected when this projectile detonates. Use the range options to determine the area effected.

(The following options are the same as those available on a TargetTracker)
Number of Targets
The number of targets returned by the TargetTracker. For example, if the sorting style is "Nearest" and there are 5 targets in range, and you enter "2" in to this parameter, then the 2 nearest will be returned on each check.

Use -1 to hit all targets in range

Sorting Style
The sorting method to use when returning the list targets.

Min [Sort] Interval
How often the target list will be sorted. If set to 0, sorting will only be triggered when Targets enter or exit range.

Range Layer
The layer the range perimeter will be added to when it is created at run-time. The perimeter is created when the GameObject with this TargetTracker is instantiated. You are given this object because the perimeter uses a collier trigger and you may wish to add it to a layer that is ignored by other physics objects in your game. We recommend creating a layer in your game called "Perimeters".
Perimeter Shape
The shape of the area that will be affected when the projectile detonates. 

Turning this check box on will display the Perimeter based on the parameters you enter. These are drawn in the editor only, are not geometry and will not render. This is just to help you setup your perimeters.

The range parameters available will change depending on the shape of the perimeter.

Notify Targets
  • Off -  Do not notify anything. delegates can still be used for custom handling. This just means nothing will be sent directly to a Target. All of the event delegates will still behave as expected, so if you subscribe to the OnFire event, your function will be called when expected.
  • On - If a target(s) is hit, it will be notified immediately and passed a HitEffect struct so it can act accordingly. 
Effect On Targets
Define the effect this fire controller will have on hit targets (ignored if "User Projectile Effects" is ON). You can define more than one, which is handy if you have a magic effect that will cause damage and slow down a target. This information is sent to targets when hit, or accessed via the API by other components. 

The target should implement the logic to determine how to respond to the effects you define here. The reason for this is that each target may have abilities that modify the effect. For example, an enemy may have a resistance to a slow effect, or a friend may have a "buff" which increases a healing effect. 

Here is a guide to using the GUI list features...
Debug Level
Set this to control the amount of information printed to the Unity Console to aid development.


This component offers several event delegates (See the code reference for more detailed information) :
Runs when this projectile is launched
Runs every frame.

OnDetonation(TargetList targets)
Runs when this projectile detonates.