Enemy AI & Pathfinding

You placed enemies in your dungeon. They spot the player and... walk directly into a wall. Stuck forever, walking in place. Or they teleport through obstacles because you gave up on pathfinding entirely.

Enemies That Don't Walk Into Walls

You placed enemies in your dungeon. They spot the player and... walk directly into a wall. Stuck forever, walking in place. Or they teleport through obstacles because you gave up on pathfinding entirely.

CraftMyGame's smart pathfinding makes enemies navigate around obstacles automatically. When an enemy spots the player, it calculates a route around walls, through doorways, and across your entire map.

- Routes around walls and obstacles - Finds alternative paths when blocked - Recalculates when the player moves - Caches paths so 50 enemies don't lag your game

Check "Use Pathfinding" on your enemy. Suddenly they navigate your level like they have a brain.

9 Pre-Built Behaviors for Every Enemy Type

You want varied enemy behavior. Guards that patrol. Merchants that wait in shops. Aggressive wolves that chase on sight. Cowardly goblins that flee when hurt.

CraftMyGame gives you nine ready-made behaviors:

Wander — Roam aimlessly with smart obstacle avoidance (peaceful wildlife, ambient NPCs)

Patrol — Walk between waypoints, with optional axis constraints for platformers (guards, sentries)

Aggressive — Hunt and attack on sight (enemies, predators)

Defensive — Attack only in territory (boss guards, protectors)

Merchant — Open shop interfaces (vendors, traders)

Quest Giver — Offer and track quests (story NPCs)

Scripted — Follow exact sequences (cutscene characters)

Flee — Run when threatened (cowards, prey animals)

Seek — Move toward specific targets (homing enemies, followers)

Each behavior is fully configurable. Patrol speed, chase range, detection radius, retreat threshold—adjust any parameter without code.

Fine-tune enemy personality:

  • Reaction timeMake enemies respond instantly or add realistic delay before they act
  • Patrol axesLock patrol routes to horizontal or vertical for classic platformer enemies
  • Obstacle avoidanceWandering enemies reverse, turn randomly, or find perpendicular paths when they hit walls

Flying, Swimming, and Ground Units—All Pathfinding Correctly

Your ground enemies navigate perfectly. You add flying enemies and they... still avoid walls, taking ground paths, even though they can fly over obstacles.

CraftMyGame's configurable pathfinding layers let different unit types follow different rules:

- Define custom layers for different movement types - Assign terrain weights per layer - Configure which obstacles each layer respects - Set entity categories that use each layer

Ground soldiers walk around buildings. Flying units ignore ground obstacles. Swimming units stay in water. Configure the rules once, and all entities follow them automatically.

Smart Enemies, Smooth Performance

You add pathfinding to 20 enemies. Fine. You add 50 enemies and suddenly everything lags because every enemy recalculates their entire path 60 times per second.

CraftMyGame's path optimization handles performance automatically:

Fine-tune the balance between responsiveness and performance. Fast-paced action games can recalculate every 100ms. Tower defense games with hundreds of units can stretch to several seconds.

100+ pathfinding enemies running smoothly because you control when calculations happen.

  • Smart cachingReuse existing paths when the player hasn't moved far (80% less calculation)
  • Path length limitsCap how far enemies will pathfind to prevent runaway calculations
  • Configurable recalculationSet exactly how often each behavior recalculates (100ms to 10 seconds)
  • Lazy recalculationOnly recalculate when targets move significantly

Detection That Makes Stealth Possible

You want a stealth game where guards have limited vision. Or a tower defense where towers have circular attack ranges. Or a horror game where the monster only detects you when you're in front of it.

CraftMyGame's detection sensors give you precise control:

Sphere — Detects anything within X tiles in all directions (tower ranges, awareness bubbles)

Cone — Detects only where the enemy faces (guard vision, line-of-sight)

Ray — Detects in a straight line from the entity (laser tripwires, line-of-sight checks)

Set range, shape, and direction. Configure sensor check intervals to balance detection accuracy against performance—frequent checks for responsive guards, slower checks for ambient creatures.

Enemies only chase targets they can actually "see." Stealth mechanics emerge naturally.

Fair, predictable detection that players can learn and master.