Enemy: Spear Thrower - Orhu/Summer2023Project GitHub Wiki

Spear Thrower (Enemy)

Overview

Belongs to the Goblins family.

The spear thrower walks towards the player and throws a spear as soon as line of sight is achieved. It will continuously throw spears until line of sight is lost, then it will move to the player until it gets line of sight again.

Finite State Machine

Spear Thrower starts in Chase state.

Chase State:
  On State Update:
    * Pathfinding Target Player
    * Chase target
  Transitions:
    * Chase to Attack
      - Condition: Is player within range AND I have line of sight to them?
      - If true: Switch to Attack
      - If false: Remain in State

Attack State:
  On State Update:
    * Attack Target Player 
    * Shoot attack
  Transitions:
    * Attack to Chase
      - Condition: Is player within range AND I have line of sight to them?
      - If true: Remain in State
      - If false: Switch to Chase