Inspector Fields

FieldTypeDescription
speedfloatTravel speed in world units per second. Default: 4.
damageintHit points removed from the first Health component hit. Default: 1.
shootSoundAudioClipPlayed once when the projectile is fired.
hitSoundAudioClipPlayed when the projectile hits a target.

Methods

MethodDescription
Shoot(ExecutionContext context, Direction direction,
Vector3 position, Quaternion rotation,
Transform parent = null) → Projectile
Instantiates a copy of the projectile prefab at position with rotation, mirrors the sprite scale to face the direction, and begins movement. Returns the new instance.

Usage example

Shoot() is called by ShootSuscriber — the built-in IExecutionSuscriber that fires the projectile each time a character executes an instruction. The instruction itself keeps Execute() empty and handles only the animation in Tick():

// ShootSuscriber.Execute — called automatically via OnExecute
public void Execute(ExecutionContext context)
{
    projectile.Shoot(context, controller.direction, transform.position, transform.rotation);
}

// The instruction plays the animation — Execute() is empty
protected override IEnumerator Tick(ExecutionContext context)
{
    context.player.SetDirection(direction);
    context.player.PlayAnimation("Shoot");
    yield return new WaitForSeconds(1.5f);
}

Attach ShootSuscriber to the player or enemy root and assign the prefab. Both PlayerController and EnemyController auto-discover it during Initialize() — no manual wiring needed.

ℹ️
The built-in ShootSuscriber IExecutionSuscriber wraps Shoot for use on players or enemies. Attach it to the character's root (or any child) and assign the prefab — both PlayerController and EnemyController auto-discover it. Use it when the character should fire a projectile on every instruction execution; for a specific shoot instruction call Shoot directly in Execute().