Description
Changelog
Reviews (0)

2D enemy AI for Godot 4: one shared state machine, readable telegraphed attacks, four enemy types and a three-pattern boss, all fighting you in one arena.

The label over each enemy is its current state. The crosshair stands in for your mouse.

Features

  • One state machine for every enemy: IDLE, CHASE, TELEGRAPH, ATTACK, RECOVERY and DEAD, in EnemyBase. Each enemy type only writes its own _ai_process().
  • Telegraphs you can read: a pulsing red circle or a red line shows where an attack is about to land, so every hit can be dodged.
  • Four behaviours:
    • Grunt chases, stops, flashes a ring and swings.
    • Skitterling weaves toward you and snaps with a very short telegraph.
    • Charger locks a direction, shows a long line, then dashes down it.
    • Boss cycles a ground slam, a ring of projectiles and a line charge, and enrages below half health with faster wind-ups and denser volleys.
  • Knockback with hit-stun, so a hit replaces an enemy's motion instead of stacking on top of a charge.
  • Juice: squash on hit, wall-slam sparks, and a death pop with gibs, a ring and a splat left on the floor.
  • Extras ready to call: make_elite() for a tougher glowing variant, ignite(dps, seconds) for burn damage, chill(factor, seconds) for a slow, and spawn_in() for an entrance effect.
  • The combat it plugs into: health, hitbox and hurtbox components, a sword with a quick and a heavy attack, and a dash with i-frames.

Requirements

  • Godot 4.7 or later, standard build (GDScript only, no .NET needed).
  • Tested on Godot 4.7.2 stable on Windows. Earlier 4.x versions are untested.
  • Uses the Mobile renderer, which needs Vulkan, Direct3D 12 or Metal.

Quick Start

  1. Press F5.
  2. Move with WASD, aim with the mouse.
  3. Left click to slash, right click for a heavy attack, Space to dash.
  4. Watch the labels: when an enemy says TELEGRAPH, its attack is coming. Step out of the red shape, or dash through it.

Known Limitations

  • Enemies steer straight at the player. There is no pathfinding, so walls between you and an enemy will block it. Add a NavigationAgent2D for levels with obstacles.
  • Enemies always know where the player is. There is no line of sight or hearing.
  • One player only: enemies target the first node in the player group.
  • No sound. EnemyBase._on_hurt() and die() are the natural places to play one.
  • Status effects (ignite, chill) and make_elite() are ready to call but nothing in the demo uses them.
  • Tested on Godot 4.7.2 on Windows only.

License

MIT for the code. See LICENSE.

Third-Party Assets

All sprites are from Tiny Dungeon by Kenney, released under CC0 1.0. Details in THIRD_PARTY_ASSETS.md, and the pack's original license is in Assets/Tiles/License.txt.

Learn How It Works

Want to understand how this works instead of just copying it?

CodingQuests teaches you how to build systems like this step by step in Godot, with interactive lessons and real projects.

  • 2D Roguelike: Enemies & AI builds this enemy system lesson by lesson: the shared state machine, the telegraphs, each enemy type and the boss. The first 3 lessons are free.
  • 2D Roguelike: Combat Core covers the health, hitbox and hurtbox components these enemies are built on. The first 4 lessons are free.

Source code, integration instructions and issue tracker: https://github.com/CodingQuests/godot-enemy-ai

Changelog for version 1.0.0

2026-10-17 01:27:08

No changelog provided for this version.

Reviews

Enemy AI has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.