# Tutorial: Learning to Drive

**URL:** <https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490>\
**Category:** Tutorial & Course Discussions\
**Tags:** unreal-engine\
**Created:** [August 28, 2023, 3:43pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490 "2023-08-28T15:43:16Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [April 16, 2024, 8:17pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/130 "2024-04-16T20:17:06Z")

</div>

Hey everyone,

We just published a new course for the 5.4 version of Learning Agents. It mainly covers the driving scenario again, and we added extra tutorials which cover the FAQs from the past months.

> **[Learning Agents (5.4) | Course](https://dev.epicgames.com/community/learning/courses/kRm/unreal-engine-learning-agents-5-4)**
>
> Get familiar with Learning Agents: a machine learning plugin for AI bots. Learning Agents allows you to train your NPCs via reinforcement & imitatio...

> Course outline
> 
> - Introduction
> 
> - Reinforcement Learning Tutorials
> 
> - Imitation Learning Tutorials

Let us know what you think!

Thanks!

---

<div class="post-metadata">

**Author:** ![Sengchor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sengchor/32/1214574_2.png) [@Sengchor](https://forums.unrealengine.com/u/Sengchor)\
**Post date:** [April 19, 2024, 4:00pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/131 "2024-04-19T16:00:28Z")

</div>

Thank you for this new tutorial.

---

<div class="post-metadata">

**Author:** ![Anonymous\_40b87656c429ba7db62f22245f4aac4d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_40b87656c429ba7db62f22245f4aac4d](https://forums.unrealengine.com/u/Anonymous_40b87656c429ba7db62f22245f4aac4d)\
**Post date:** [April 26, 2024, 3:03pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/132 "2024-04-26T15:03:42Z")

</div>

How do I enable training mode after packaging? Can it be done by manually executing the Python files located in the Engine\Plugins\Experimental\LearningAgents\Content\Python directory?

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [April 29, 2024, 12:23pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/133 "2024-04-29T12:23:18Z")

</div>

Do you need to just follow the headless instructions here: [Learning Agents (5.4) | Course](https://dev.epicgames.com/community/learning/courses/kRm/unreal-engine-learning-agents-5-4/2J2B/unreal-engine-headless-training-network-snapshots) ?

---

<div class="post-metadata">

**Author:** ![krz9000](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/krz9000/32/499235_2.png) [@krz9000](https://forums.unrealengine.com/u/krz9000)\
**Post date:** [May 18, 2024, 11:56am UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/134 "2024-05-18T11:56:17Z")

</div>

i found that the spline in the sportcar pawn is not set in the reset to random point function. after adding this node it worked. might be a BP copy paste issue…but i wanted to mention it if others wonder why nothings happens after you press play (just the logfile fills up complaining that this spline is undefined)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/7/fd789c9bbf3e1070dc7f15160bfeb8005d11cc65.png)

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [May 21, 2024, 6:02pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/135 "2024-05-21T18:02:52Z")

</div>

Yeah this is an annoying part of copying the code samples to UE. Hmm I wonder if I can suggest they fix it.

---

<div class="post-metadata">

**Author:** ![Qbsoon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Qbsoon](https://forums.unrealengine.com/u/Qbsoon)\
**Post date:** [July 15, 2024, 12:52pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/136 "2024-07-15T12:52:50Z")

</div>

@Deathcalibur  
I tried using the tutorial to try teach a cube on thirdparty template to move along non-closed spline, but it didn’t work as expected, so I switched to vechicle template and this time did step-by-step with the tutorial, but when I run I get this error:

```auto
LogLearning: Error: SportsCarTrainer_0: Can't find Python executable "../../../Sandbox/MachineLearning/LearningExamples/Intermediate/PipInstall/Scripts/python.exe".

```

There were similar errors mentioned above, but on Mac and Linux, but I run windows.  
Windows 11, UE5.4.2-33871570

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 15, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/137 "2024-07-15T14:08:49Z")

</div>

Check this thread: [Can't find LearningAgents plugin Content](https://forums.unrealengine.com/t/cant-find-learningagents-plugin-content/1907114)

---

<div class="post-metadata">

**Author:** ![Qbsoon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Qbsoon](https://forums.unrealengine.com/u/Qbsoon)\
**Post date:** [July 16, 2024, 10:33am UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/138 "2024-07-16T10:33:28Z")

</div>

@Deathcalibur  
This thread issue concerns non-editor paths. I have a problem with running in-editor and my paths are default editor paths (same as in the other, cube project, which can run). If I need to edit these editor paths somehow, I don’t know what should I change them to.

```auto
../../../Engine/
../../../Sandbox/MachineLearning/LearningExamples/Intermediate/

```

EDIT: Ok, manually browsing editor intermediate to the intermediate folder kinda fixed it

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 16, 2024, 1:04pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/139 "2024-07-16T13:04:46Z")

</div>

Oh hmm sorry if I didn’t read your question properly. I’m glad you figured it out.

If we have some time, will think more about if we can fix this issue better as several people run into it.

---

<div class="post-metadata">

**Author:** ![QuicKTricKz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/quicktrickz/32/547676_2.png) [@QuicKTricKz](https://forums.unrealengine.com/u/QuicKTricKz)\
**Post date:** [July 16, 2024, 5:35pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/140 "2024-07-16T17:35:50Z")

</div>

I would be very interested in seeing a similar reinforcement learning tutorial but for an FPS Unreal Tournament type game. How much of a difference would there be? Any guidance would be much appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 16, 2024, 5:48pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/141 "2024-07-16T17:48:16Z")

</div>

In my opinion, it’s not too different but I’m obviously super biased to my point of view since we made learning agents haha.

I have not yet trained an agent in a shooter using RL yet (but have done imitation learning). Learning Agents works for it in theory (not that its a perfect library/tool… yet). The part that isn’t really fleshed out well in 5.4 is how to scale out.

You can google around and find the current state of the art:

> **[Capture the Flag: the emergence of complex cooperative agents](https://deepmind.google/discover/blog/capture-the-flag-the-emergence-of-complex-cooperative-agents/)**
>
> Mastering the strategy, tactical understanding, and team play involved in multiplayer video games represents a critical challenge for AI research. In our latest paper, now published in the journal...

Brendan

---

<div class="post-metadata">

**Author:** ![simonbrislin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@simonbrislin](https://forums.unrealengine.com/u/simonbrislin)\
**Post date:** [July 17, 2024, 1:49pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/142 "2024-07-17T13:49:08Z")

</div>

Hi,

I saw on some of the 5.3 replies that people were having issues with the cars learning to accelerate but not turn but couldn’t find a solution.

I’ve followed the 5.4 tutorial exactly I _think_ and they learn to accelerate and learn to steer left (to some extent) but they never make it through a corner unless they are travelling very slowly. Bizarrely they are incapable of turning right too. They have been training for over 2 hours.

I’ve tried the 5.3 and the 5.4 tutorial on their respective engines and saw the same thing on both. Any idea what could be going wrong?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![simonbrislin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@simonbrislin](https://forums.unrealengine.com/u/simonbrislin)\
**Post date:** [July 17, 2024, 2:04pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/143 "2024-07-17T14:04:49Z")

</div>

I’ve just noticed that ResetToRandomPointOnSpline wasn’t working correctly because I was using variables as opposed to local variables. That is now fixed and I’m running it again. Hopefully this will help.

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 17, 2024, 3:50pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/144 "2024-07-17T15:50:37Z")

</div>

Thanks for all the feedback everyone. Anytime people find issues or run into challenges, I try to take the time to figure out how to make the tutorials or code better. That’s my intention at least 🙂

Brendan

---

<div class="post-metadata">

**Author:** ![simonbrislin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@simonbrislin](https://forums.unrealengine.com/u/simonbrislin)\
**Post date:** [July 17, 2024, 3:54pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/145 "2024-07-17T15:54:40Z")

</div>

Hi Brendan,

Can I recommend highlighting the local variables thing as a potential gotcha? Using global as opposed to local variables seems to entirely break the training and it’s very easy to miss.

I’m still training but it’s progressing much better now.

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 17, 2024, 7:19pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/146 "2024-07-17T19:19:04Z")

</div>

@simonbrislin - I added a callout to the tutorial stating to use a local variable. Hopefully that helps other users not run into the same problem. Let me know if I made a mistake; otherwise, thanks for speaking up!

Brendan

---

<div class="post-metadata">

**Author:** ![simonbrislin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@simonbrislin](https://forums.unrealengine.com/u/simonbrislin)\
**Post date:** [July 18, 2024, 9:38am UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/147 "2024-07-18T09:38:47Z")

</div>

@deathcalibur yeah I think that callout helps.

I think the only thing that I am remaining stuck on is that the episodes seem to always end early. I can’t figure out if it’s a too short max episode length or there’s some bug in my blueprints that is causing it to end early. I think this is causing the one remaining issue - which is that the vehicles never seem to go that fast - they top out at about 70kmph.

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [July 18, 2024, 12:54pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/148 "2024-07-18T12:54:59Z")

</div>

That’s very strange. I don’t have time at the moment to help everyone debug their code (I wish I did!), so the best I can say is let me know if you figure out the problem and then I will definitely do something about it if I can.

Brendan

---

<div class="post-metadata">

**Author:** ![simonbrislin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@simonbrislin](https://forums.unrealengine.com/u/simonbrislin)\
**Post date:** [August 6, 2024, 4:43pm UTC](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490/149 "2024-08-06T16:43:46Z")

</div>

Hi Brendan,

Is there a way to get the current iteration while training? I am trying to do my own saving networks to snapshots and would like to do it at iteration 100, 200, 300 etc. or similar but can’t figure out how to get the iteration number.

Thanks in advance

[Previous page](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490.md?page=6)

[Next page](https://forums.unrealengine.com/t/tutorial-learning-to-drive/1275490.md?page=8)
