State Machine AI implementation for a Boss Enemy.
Boss Functionality
The boss enemy is driven by a state machine that transitions through five distinct phases based on its current health. Each phase introduces new behaviors and attack patterns, gradually increasing the complexity and challenge as the player progresses through the fight.
- Phase 1: Uses a combination of a static attack (e.g., predefined hit zone) and a dynamic, position-based attack that targets the player's movement or location.
- Phase 2: A defensive phase where the boss becomes invulnerable and spawns waves of enemies to protect itself.
- Phase 3: Adds a new static attack and introduces projectile-based attacks into its arsenal, forcing the player to adapt to ranged threats.
- Phase 4: Another defensive phase with increased enemy spawns and continued invulnerability, keeping pressure on the player.
- Phase 5: The boss unleashes all previous attacks in sequence, creating a final, high-intensity showdown.
Additional Functionalities
Several supportive systems are implemented to enhance the boss’s behavior and performance:
- Attack Pool: Reuses instances of both static and dynamic attacks for efficiency and better control.
- Projectile Pool: Manages reusable projectile instances for the boss’s ranged attacks, reducing runtime allocations.
- Intro & Outro Cutscenes: The boss battle is framed with cinematic intro and outro sequences, adding polish and narrative tension. View my Projectile Pool on GitHub
Phase Demonstrations
Phase 1 - Basic Attack Combo
The boss uses a slow but deadly combination of a static AoE and dynamic attack aimed at the player’s position.

Phase 2 - Defensive Enemy Spawning
While invulnerable, the boss calls in enemy reinforcements to protect itself and overwhelm the player. These enemies must be cleared before progressing.

Phase 3 - Enhanced Offense
The boss escalates with new projectile attacks that require constant movement and dodging. This phase tests ranged awareness and positioning.

Enemy Spawning Showcase
A look at the spawning logic during Phase 2 and 4. Spawned enemies work alongside the boss and add complexity to the battlefield.
