🚀Projectile
v1.0
Last updated
v1.0
Last updated
A Projectile is the GameObject
that gets spawned and (probably) moves around the world looking for a target to smash into.
The Projectile component has a number of Scriptable Objects
which determine how the projectile behaves in the world, from spawning, to motion, destruction, speed, and more.
The custom Inspector is where you add all the details required to make an awesome projectile! The overviews below will introduce you to each section. Check the detailed pages for complete information.
The Scriptable Objects
referenced in the Projectile Inspector can be edited directly in this view. However, the data still lives on those objects, so any changes to the Scriptable Object
data here will affect all other Projectiles which use the same data or behaviors.
You can click the "Replace w/ Copy" button to create a copy of any behavior, to customize it without affecting other projectiles.
Each Projectile needs a Projectile Data object attached to it. This will hold specific data like speed or other things, which the Behaviors will make use of.
You may want to create a class which inherits from ProjectileData
, to include custom information and logic for your project.
The Spawn Behavior for the Projectile, along with any Spawn Behavior Modifications determine how the projectiles are spawned. This includes the speed at which they are spawned, and even how many -- from a single projectile to a machine gun, and more.
The Spawn Behavior Modifications are optional behavior scripts that fire once, right after the Projectile is spawned, and before any Behaviors activate. You can have as many Spawn Behavior Modifications as you'd like.
In the demo scenes, any "Laser" Projectile will have a "Parent to Spawn Point" modification, which ensures the Projectile is parented properly to the spawn point, so it can rotate as expected.
Many Projectiles also use a Spawn Behavior Modification to create a "Muzzle" particle, as shown above.
Behaviors determine how the Projectile behaves (get it?). From movement through collision and destructions, each Behavior will typically do a single thing. This allows you to quickly build up the behavior of any particular Projectile, and easily modify behaviors to create the perfect Projectile for your project.
You can also create your own Behaviors! If you want something that doesn't exist already, it's easy to create a new behavior, or override an existing one to customize things exactly as you'd like for your project.
Each Projectile has UnityEvents
exposed, allowing you to hook into the Projectile lifecycle.
The Projectile itself is a Scriptable Object
, so it can not have any scene objects added to the UnityEvents
. To make use of these events, check the "Projectile Events" tab on the Projectile Spawner.
The UnityEvent
settings in that section will be copied to every Projectile the spawner creates, allowing for in-scene hooks to each Projectile.
The Factory Manager allows for Global Observers to react based on all projectile lifecycle events. Toggle this off if you do not want this projectile to register itself with the Factory Manager.
Keep this toggle on to use the built in Object Pooling system. When false, this projectile will instantiate and destroy during runtime.
Each projectile can have an optional pre-launch Trajectory, intended to provide some sort of indication to the player about where the projectile may go. Projectile Factory ships with a few trajectories, and you can create your own as well.