Hi guys i just wanted to learn how to incorporate machine learning into my Unity projects. I watched this tutorial from Code Monkey but slightly modified it to work in 2026 since the vid is pretty old. My friends were interested in learning how to do this too so I'm writing this detailed readme for them but if you happen to stumble upon this I hope its somewhat useful or interesting.

Ok so this is the official doc with all the install instructions but I did it slightly differently. I'll write down how I did it but please note I am using Unity 6 with Windows 11 so there may be variations across different OSs. Also, im not going over the stuff done in the Unity editor. You can find that information in the video and documentation.
- First you wanna install Python 3.10 (My first mistake was attempting using Python 3.14)
- Make a folder for your project. You'll build your Unity project here as well as set up a virtual environment
- cd to your folder and type py -3.10 -m venv venv to create your virtual environment
- activate with venv\Scripts\activate
- now that you're in the virtual environment, write these commands in order:
- pip install mlagents==1.1.0
- pip install "torch==2.2.2" --index-url https://download.pytorch.org/whl/cu121
- mlagents-learn --help (this is just to check if its installed)
To run and start training the agent type:
mlagents-learn
This should pop up. Press play in the editor to start training.

After running the first time you may notice an error preventing you from running again. In subsequent runs, type either:
- mlagents-learn --run-id=[your choice]
- mlagents-learn --force
I'm gonna assume you have Unity (6) installed and C# .NET stuff setup since this is a unity project afterall but if you don't here's some material:
- Unity Manual
- C#/.NET download (I also highly recommend getting the Unity add-ons for your IDE)