Unreal Engine 5 Enemy AI #3 – Chasing the Player & Forgetting System

Unreal Engine 5 Enemy AI #3 – Chasing the Player & Forgetting System

Part 3 of the UE5 Enemy AI Series. Learn how to make enemies chase the player using AI Perception (Sight), speed changes, and Unreal’s forget system—then return to patrol automatically.

Welcome back to the Unreal Engine 5 Enemy AI Series!

This is one of the most important mechanics for believable AI: enemies shouldn’t chase forever, but they also shouldn’t instantly forget you. We’ll configure Unreal’s AI Perception, tweak project settings, and wire everything in Blueprints only.


🎯 What You’ll Learn


📝 Chapters


⚙️ Step 1: Configure AI Perception (Sight)

Open BP_EnemyGuard and select the AI Perception component.
In Details → Sight Config:

💡 Important Gotcha:
Max Age is not directly readable in Blueprints (it won’t update live). Instead, we rely on Unreal’s internal forget system.


⚙️ Step 2: Enable Forget Stale Actors (Project Settings)

Go to Edit → Project Settings → Engine → AI System.
Enable: Forget Stale Actors

Without this, enemies never truly forget targets, no matter the Max Age. This single setting makes the whole system work.


⚙️ Step 3: Patrol Speed vs. Chase Speed

Select Character Movement component in BP_EnemyGuard:

Later, when chasing the player, we’ll temporarily set this to 500.


⚙️ Step 4: Blueprint – Chasing the Player

  1. Select AI Perception component → scroll to Events → click On Target Perception Updated (+).
  2. A new event node appears.
  3. From Actor pin, drag off → Cast to Player Blueprint (e.g. BP_ThirdPersonCharacter).
  4. Drag Character Movement component into graph → connect to Set Max Walk Speed = 500.
  5. Add AI Move To:
    • Pawn = Self
    • Target Actor = Player cast reference

👉 Now, when AI sees the player:


⚙️ Step 5: Blueprint – Forgetting the Player

  1. Select AI Perception componentOn Target Perception Forgotten (+).
  2. Add event node.
  3. From Actor pin → Cast to Player Blueprint (same as above).
  4. Set Max Walk Speed = 300 (return to patrol pace).
  5. Connect execution to Get All Actors with Tag (patrol logic from Part 2).

⚙️ Step 6: Binding the Forget Event

Unreal doesn’t auto-bind the Forget event.


⚙️ Step 7: Debugging the Forget System

Add debug print:

  1. After Forget event fires → Format Text node.
    • Format string: AI forgot {Actor}.
  2. Connect Actor pin.
  3. Pipe into Print String.

👉 Now when AI forgets the player, you’ll see a message in the viewport and log.


⚠️ Step 8: Troubleshooting AI Bugs

Sometimes AI doesn’t update after changes. Common causes:

  1. Old actors in level

    • Delete BP_EnemyGuard instances.
    • Drag fresh copies into level.
    • Reassign tags (path1, path2).
  2. Stale cache folders

    • Close Unreal.
    • Delete Intermediate and DerivedDataCache from project folder.
    • Reopen project (Unreal rebuilds them).

💡 This fixes 90% of “AI stuck” issues after changing perception or Blueprint logic.


🎥 Testing

👉 Note: In UE5.6, sometimes only one AI shows in visualizer (quirk). Behavior still works fine.


✅ Summary

By now, your AI can:

This is the foundation of believable AI—not too robotic, not too dumb.


📦 Project Files → GitHub Repo
🌐 More Tutorials → rambod.net
💬 Drop questions in comments → I reply to all.
🔔 Subscribe for Part 4: Sound Sensing & Chasing Upgrades


📺 Watch the full tutorial:
👉 https://www.youtube.com/watch?v=1U19AJxCpNw

Code