# Learning Agents: Trained in One Map, Fails in Another Map - Error Occurred

**URL:** <https://forums.unrealengine.com/t/learning-agents-trained-in-one-map-fails-in-another-map-error-occurred/2666500>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, crash, Learning-Agents, Blueprint, question\
**Created:** [October 18, 2025, 1:46pm UTC](https://forums.unrealengine.com/t/learning-agents-trained-in-one-map-fails-in-another-map-error-occurred/2666500 "2025-10-18T13:46:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RERocowolf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RERocowolf](https://forums.unrealengine.com/u/RERocowolf)\
**Post date:** [October 18, 2025, 1:46pm UTC](https://forums.unrealengine.com/t/learning-agents-trained-in-one-map-fails-in-another-map-error-occurred/2666500/1 "2025-10-18T13:46:47Z")

</div>

Hello everyone,

I’m encountering a generalization issue with the Learning Agents plugin in Unreal Engine 5.6.1 and would appreciate your help. Here is my detailed setup and the problem:

**Environment:**

- Unreal Engine: **5.6.1 (Source Build)**

- Project Template: `Vehicle`**Template (5.6.1 version)**

- Learning Agents Tutorial: Followed the **5.5 version tutorial**.

- Training Map: `VehicleTemplate` (the default map from the Racing Template).

- Target/Inference Map: `Variant_Timetrial` (another map from the same template).

**Steps I Took:**

1. **Successful Training:** I successfully trained my agents in the `VehicleTemplate` map. Everything works as expected during training.

2. **Setup in New Map:** To run inference in the new map `Variant_Timetrial`, I did the following:

3. **The Error:** At this point, the editor **throws an error** and the inference fails.

**Code Modifications (Deviations from Tutorial):**

Compared to the standard tutorial, I made several key modifications to the BluePrint to address issues in the `VehicleTemplate` map:

- `ResetToRandomPointOnSpline` **Function:**

- `BP_SportsCarTrainingEnv` **Blueprint:**

**The Critical Clue:**

Following the tutorial, I have a logic node that cleans up the network. The `bool` input for this node is defined as: `NOT (Continue Train OR Run Inference)`.

- If I check `Continue Train` (and leave `Run Inference` unchecked), the editor does **NOT** crash. This suggests the agent and manager setup is fundamentally valid.

- The error **only occurs** when I check the `Run Inference` box (and leave Continue Train unchecked).

**My Question:**

Why would my trained model work perfectly in the training map but fail with an error when switching to a new map for inference? **Most importantly, why does the** `GatherAgentObservation` **function in** `BP_SportsCarInteractor` **sometimes receive an invalid** `ObsActor` **during inference in the new map, leading to a crash?** Could this be related to my custom reset logic or the way agents are managed when switching from training to inference mode in a different environment?

Why does the `Run Inference` flag trigger the error while `Continue Train` does not? Given my customizations, could the issue lie in the interaction between my modified `ResetToRandomPointOnSpline` function, the overridden `ResetAgentEpisodes` node, and the different spline/data in the new map during inference?

**What I’ve Considered:  
T **hrough debugging, I discovered that within the `GatherAgentObservation` function of `BP_SportsCarInteractor`, the `GetAgent` call sometimes returns an** invalid** `ObsActor`. This is the direct cause of the error, as subsequent operations (like printing the actor’s location) fail. (I have attached screenshots of the debug print and the error).

 ![{CD2BAEB4-E4BF-4131-8588-5351867EF890}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/6/446dd24768eb67cffb1c25d85aad143a6e9003ca.png) ![{9847425F-3DFE-4af3-A7E7-8FFA79AFFAD1}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/e/e6e368feca5983b6bc5925254f7f79ed8469848d.png)

Any insights into the root cause or steps to debug this would be immensely helpful. Thank you for your time and expertise!

---

<div class="post-metadata">

**Author:** ![RERocowolf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RERocowolf](https://forums.unrealengine.com/u/RERocowolf)\
**Post date:** [October 21, 2025, 2:15pm UTC](https://forums.unrealengine.com/t/learning-agents-trained-in-one-map-fails-in-another-map-error-occurred/2666500/2 "2025-10-21T14:15:38Z")

</div>

The issue has been resolved. The problem was caused by a small defect in the navigation mesh, which allowed the agents to fall out of the world and be automatically culled by the system.😂

---

<div class="post-metadata">

**Author:** ![silentkratos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@silentkratos](https://forums.unrealengine.com/u/silentkratos)\
**Post date:** [May 4, 2026, 3:50am UTC](https://forums.unrealengine.com/t/learning-agents-trained-in-one-map-fails-in-another-map-error-occurred/2666500/3 "2026-05-04T03:50:01Z")

</div>

Hi.  
Would it be possible to share your example project?  
I followed the tutorial on Epic’s website:

> **[Learning Agents (5.5) | Course](https://dev.epicgames.com/community/learning/courses/GAR/unreal-engine-learning-agents-5-5/7dmy/unreal-engine-learning-to-drive-5-5#sportscarobservations)**
>
> Get familiar with Learning Agents: a machine learning plugin for AI bots. Learning Agents allows you to train your NPCs via reinforcement & imitation le...

But half the scripts have broken links now.

Thank you in advance.
