
2D Platformer – Enemy AI System
An AI-driven enemy system featuring chase, jump logic, combat interaction, health, and loot drops.
Overview
The Enemy AI System introduces dynamic challenges to the player.
Enemies patrol, chase, and jump toward the player using raycasts to detect the environment and react intelligently.
They deal damage on contact, take damage from the player’s attacks, and drop loot items when defeated.
The system includes health handling, visual feedback (sprite flashing on damage), and configurable loot tables with rarity percentages.
This makes enemies feel alive, responsive, and rewarding to defeat.
Development & Behavior
- Chasing: Enemies detect the player’s horizontal position and move toward them using directional velocity.
- Jumping: Raycasts check for obstacles, gaps, and platforms above. If blocked, enemies jump toward the player with calculated force.
- Ground Detection:
Physics2D.Raycastensures enemies only chase and jump when grounded. - Damage System:
- Player contact inflicts damage.
- Enemies flash white briefly when hit, then return to their original color.
- Health: Configurable
maxHealthandcurrentHealthensure scalable difficulty. - Loot Drop: Randomized loot table determines if gems, health, or boosts drop upon death.
- Sound & Feedback: Integrated with
SoundEffectManagerto trigger hit sounds.
Visual Evolution — Before vs After
Early Prototype
The early enemy used placeholder sprites with minimal animation. Movement was rigid, and there was little feedback when taking damage. Loot drop visuals were basic and lacked variation.

Polished Build
The final version features stylized pixel art enemies, smooth chase and jump behaviors,
flashing feedback when damaged, and visually distinct loot drops.
Combined with refined animations, they feel integrated into the polished world.

Enemy Sprites & Animations
Idle / Patrol
When idle or patrolling, enemies keep subtle animations — blinking or shifting — to feel alive.

Chase Animation
The chase animation syncs with horizontal velocity. Dust effects are added for urgency as they run toward the player.

Future Scope
- Smarter AI with state machines (patrol, chase, retreat).
- Ranged enemies with projectiles.
- Boss enemies with unique patterns.
- More varied loot tables (rare drops, power-ups).
- Animation blending for smoother transitions.
Play Demo
Play Enemy Showcase (prototype link)