Spawn Behavior Code
v1.0
I hope you find the code easy to read and understand. This page will introduce the main methods which you may wish to know about. However, in general use, you don't need to handle any of the code, unless you are creating a new Spawn Behavior class, and plan to override some of the methods, or add new logic.
Launch
The ProjectileSpawner
class will call this to launch projectiles -- consider it the thing that gets called when the trigger is pressed, or other similar thing occurs. Based on the MultiShotBehavior
settings, this may actually be blocked.
This method will start a LaunchProjectiles
coroutine.
Stop
If forceStop
is true
, the coroutine will stop even if canStopMidSpawning
is set false
.
This is the method which stops the spawning of projectiles. There are many reasons to do so, including perhaps the player taking their finger off of the trigger.
Launch Projectiles (Coroutine)
This is the loop that actually Spawns the projectiles (using the SpawnProjectile
) method. It handles the calculation of where and at what angle, and the repetitions and delays.
SpawnProjectile
This method will create the projectile, first by pulling one from the Projectile Object Pool, or by instantiating a new one if there are none available in the pool. Setup actions on the Projectile itself are called from this method as well.
Do Spawn Modifications
Called from SpawnProjectile()
, this occurs prior to any events called on the projectile, and will call the OnSpawn()
method on each of the SpawnBehaviorModification
objects attached ot this Projectile
.
Start Position
This method will return the start position for a specific projectile based on the index provided.
Launch Position
This works in conjunction with StartPosition()
to determine the position of the projectile based on the angles provided. In some cases, the position will be offset from the default spawn position.
Additional Methods
There are additional methods you may find of interest, if you open the script. There are multiple "Determine..." methods which handle the launch orders, as an example.
Last updated