Projectile Code

v1.0

Properties

The Projectile has a number of (mostly virtual) properties ready to be used.

public SpawnBehavior SpawnBehavior
public bool IsInPool
public bool Launched

public int CountObservers
public List<ProjectileObserver> Observers

public int CountBehaviors => behaviors.Count;
public List<ProjectileBehavior> Behaviors => behaviors;

Notable Methods

Check the class itself for all the methods. I'll cover the most interesting ones here.

ResetProjectile()

This is called automatically when the Projectile is returned to the Object Pool. It can also be called manually if you have a need to do so.

AddToCollisionMask() and RemoveFromCollisionMask

Pass a LayerMask into these methods to either Add or Remove those values.

[IMPORTANT] This will have no effect in game unless overrideCollisionMask is true!

AddObserver() and RemoveObserver()

AddObserver() lets you pass in Projectile Observer to add to the list of Observers. RemoveObserver() will do the opposite.

TriggerCollisionWithObject()

TriggerCollisionWithObject(GameObject objectHit, Vector3 pointOfContact = default) will force the Projectile to register a collision with the specified object, triggering all events associated with that on the Behaviors assigned.

AddBehavior() and RemoveBehavior()

Use these methods to add or remove a Behavior from the projectile.

Last updated