Creating a Game with Learning AI in Unity! (Tutorial / Machine Learning) -

Creating a Game with Learning AI in Unity! (Tutorial / Machine Learning)

Views: 109777
Like: 2380
Making a game and programming AI behaviour is a lot of fun. But it’s even more fun, and in certain cases more efficient, where the AI can learn by its own mistakes and the different player behaviours! Let’s take a look at using Machine Learning to create smart AI for our Unity games.

Get access to the Karting Microgame here:
More information on the Machine Learning Agents Toolkit:

BehaviourParameters on Github:


  1. I remembered using this 1 year ago and it's fun, however you gotta install Tensorflow and the setup is not user-friendly(another beta), not sure how it is today though

  2. thank you for showing how to use the Command prompt, i ran into an error when i did this on the lesson from learn.unity than you for this tutor

  3. I wonder in ML agents preview do you need all these steps do or something is changed with installation?

  4. How To Scam Children Into Thinking Your Game Is Multiplayer: The Video

  5. You can have 5 billion tris in a scene, but if the AI is dumb, the game is dumb.

  6. Well done unity! I Will try (as a newbie) to apply this to a combat game i'm developing.
    Thanks a lot

    Wondering if i Need more brain (nn file) in order to let the player win a little XD
    I mean , for difficulty setting…

  7. I really like how Unity themselves using light theme. It looks so familier

  8. Finally!!! We can make a fake multiplayer battle royale game with this!!!

  9. Can I use this method if I have procedurally generated tracks? 🙃

  10. Please tell about the android input for the movement for these kind of games

  11. This workflow is AWFUL!

    You have to do better than this.

  12. Atleast use dark mode in Tutorials… Please

  13. Is that bad to say I'm kinda impress by this text2speech vocal synthesis more than this self training cart based on (D)ML ?

  14. Hey, why you don't use ML .Net for training?

  15. This is a good tutorial, but good lord my command prompt window does not want to cooperate with me, as when I try it, I get this:
    "[FolderPath]>python -m venv venv"


    "The system cannot find the path specified."

  16. Teach us how to teach bipedal characters to walk!

  17. Everything worked fine until I reached the point at 11:35, it says mlagents-learn is not reconized. as internal command :(. The previous steps with python worked fine and im in the virtual enviroment exacly as in the video.

  18. Hi,
    I'm having a trouble with venv. I'm on windows and have Python 3.7.7 installed., The creation of the venv does'nt appear to be a problem, but when I try to activate the scripts, with the correct syntax, it's appears that thje path can't be found. Do you have any ideas why?

  19. It's cool but I'm thinking about the uses. If someone is going to say that this can be used for training bots, so as to compete with the user, then writing a script is far simpler, or, if you are going to train cars in a different way to act as opponents, still, a script can be written. It's really cool but using this creatively is key! any ideas peeps?

  20. Unity cant afford their own dark theme subscription…

  21. Is this tutorial even helpful? It’s running through the command prompt which is super weird, and this also means you can’t train an AI in an actual game someone would play. Also, this seems super specific and probably not applicable to anything else. This tutorial seems useless

  22. "[FolderPath]>venvScriptsactivate"

    "The system cannot find the path specified."

    Has anyone a solution why this problem occurs ?

  23. When everything works and a error message occurs as soon as you type
    mlagents-learn AssetsKartingPrefabsAIkart_mg_trainer_config.yaml –train –run-id=custom-track-1
    Check if there is a sentence saying something like "Python API-12, Unity API-13". If this is the case change
    pip install -Iv mlagents==0.12.0 to
    pip install -Iv mlagents==0.13.0
    So that the python version matches with the Unity one.

  24. i dont rly know python so i probably can study from this video in future

  25. for error "mlagents.trainers.exception.TrainerConfigError: The option default was specified in your YAML file, but is invalid." They have changed format of yaml so they provide command you may execute this:
    python -m mlagents.trainers.upgrade_config AssetsKartingPrefabsAIkart_mg_trainer_config.yaml AssetsKartingPrefabsAIkart_mg_trainer_config_new.yaml

  26. (venv) G:UnityProjcars1>mlagents-learn AssetsKartingPrefabsAIkart_mg_trainer_config.yaml –train –run-id=custom-track-1

    "mlagents-learn" is not internal or external

    command, executable program, or batch file.

    why is there such an error?

  27. woah he is doing this at 9 50 and i am doing it at 9 52

  28. If anyone is still having trouble with "python -m venv venv" and you are on windows go into your command prompt and type python it will launch the Microsoft store and then download that python let it install and once it is done close and reopen your cmd then type "python -m venv venv" and it will work.

  29. My cube isn't showing the yellow direction vector and my agents keep falling off the track. What am I doing wrong? I added the cubes to the colliders

  30. I keep getting errors when i type in cd documents in my terminal and I'm using a mac so I'm having a bit trouble with this. Please help. Anybody!

  31. When I type cd DocumentsProjectsUnitykart-microgame on terminal, it says File "<stdin>", line 1
    SyntaxError: unexpected character after line continuation character
    I need help with this one please. It's been giving me a headache all day

  32. how to integrate my own text to speech api into Unity? Any help would be appreciated! What I want to create is to make my own character talk to me in normal human beings way via my API. How can I do that?

  33. When I try to download this package, it tells me that it only works with a previous version of Unity. I'm not gonna download an old version of the engine. Come on, just make the asset available for any version and let us follow through.

  34. lol Dani, a Unity youtuber/developer has more subs than Unity

  35. Waaaaaaaaaaaaaaaait a second . External library TENSORFLOW but in reality you guys use PyTorch ? Am I not getting something guys ?

  36. i have errors when i type mlagents-learn AssetsKartingPrefabsAIkart_mg_trainer_config.yaml–train –run-id=custom-track-1

  37. how can we train multiple brains at same time (or apply genetic algorithm) using ml-agents

  38. unable to find Kart Academy in the AI section

  39. sorruy i have a question, the Kart Academy is missing in my unity package. did i miss anything ?

Leave a Reply

Your email address will not be published.