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 RexPool to spawn the individual instances of the Projectile.
public void Fire(Vector2 _startingPosition, Direction.Horizontal _horizontal, Direction.Vertical _vertical = Direction.Vertical.Neutral, RexPool _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 RexPool 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 or enemies.
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 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 CollisionSide ricochetOnTerrainCollision
This has checkboxes for onCeiling, onFloor, onLeft, and onRight. The projectile will ricochet when it collides with terrain on any of the checked sides.
public CollisionSide destroyOnTerrainCollision
This has checkboxes for onCeiling, onFloor, onLeft, and onRight. The projectile will be destroyed when it collides with terrain on any of the checked sides.
public float acceleration
If set above 0.0f, the projectile will accelerate to its top speed by this value.
public DirectionChange directionChange
Contains values for how many frames the projectile will move in a certain direction before reversing direction. If swapOnActorFlip is True, the left and right values will reverse when the actor firing this projectile turns around.
public int horizontalFlipsAllowed
Used in conjunction with the directionChange values set above to determine how many times the projectile is allowed to reverse its horizontal direction.
public int verticalFlipsAllowed
Used in conjunction with the directionChange values set above to determine how many times the projectile is allowed to reverse its vertical direction.
public RexPool parentSpawnPool
If this is spawned via a RexPool, set this to the pool that spawned it; this will enable it to despawn from the same pool.
public RexActor spawningActor
A reference to the RexActor 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.