Projectile is the base class for bullets. It lets you slot AudioClips and AnimationClips to play during various states of the Projectile, as well as determine if the Projectile should be reflected upon contact with a Reflector component. It’s designed to be used in conjunction with a ContactDamage component so that it will damage actors it touches. It’s also especially effective when paired with a JetPool to spawn the individual instances of the Projectile.
public void Fire(Vector2 _startingPosition, Direction.Horizontal _horizontal, Direction.Vertical _vertical = Direction.Vertical.Neutral, JetPool _parentSpawnPool = null)
Fires the projectile. _startingPosition governs the location where the projectile spawns and begins firing from. _horizontal governs the horizontal direction the projectile fires in, and _vertical is the vertical direction. _parentSpawnPool passes in the JetPool which spawned the Projectile, if any, and allows the Projectile to communicate with it for certain events.
public override void Clear()
Either despawns the Projectile if parentSpawnPool is set, or calls Destroy() if not.
public void OnSpawned()
Initializes the starting values for the projectile. This is called automatically by the Projectile’s OnEnable().
public DestroyOnHit willDestroyOnHit
Properties determining if this Projectile is destroyed when it hits the Player, enemies, or terrain.
public Reflection reflection
Properties relating to what can reflect this Projectile and how it behaves once reflected.
public Animations animations
Here, you can slot AnimationClips for the default, spawning, and death of this Projectile.
public Sounds sounds
Here, you can slot AudioClips for the fire, death, and reflection of this Projectile.
public Vector2 movementSpeed
The movement speed of this projectile on both the X and Y axes.
public ForceType verticalForceType
Can be set to either Continuous, in which case its vertical velocity is applied every frame, or Initial, in which case its vertical velocity is applied only on the first frame when it fires.
public ContactDamage contactDamage
If this GameObject has a ContactDamage component, it can be slotted here. Doing so allows the contact damage properties to change if the Projectile is reflected.
public bool willDestroyWhenOffscreen
Whether or not the Projectile will be destroyed as soon as it leaves the field of view of the main camera.
public bool willDestroyWhenSceneChanges
Whether or not the Projectile will be destroyed if a new scene is loaded.
public bool willShakeScreenOnDeath
Whether or not the Projectile will shake the screen when it dies.
public float rotationSpeed
Setting this higher than 0 lets the projectile sprite rotate each frame it’s being fired.
public JetPool parentSpawnPool
If this is spawned via a JetPool, set this to the pool that spawned it; this will enable it to despawn from the same pool.
public JetActor spawningActor
A reference to the JetActor that spawned this, if any.
public Attack spawningAttack
A reference to the Attack that spawned this, if any.
public Direction.Horizontal horizontalDirection
The horizontal direction the Projectile is facing.
public Direction.Vertical verticalDirection
The vertical direction the Projectile is facing.