Unity does not recognise MLAgents namespace

Hello,
Im making a 2D game and trying to set up some agents, so I installed ML Agents using the package manager, but when I try to make the agent scripts I keep getting the error
Assets/PlaneAI.cs(4,7): error CS0246: The type or namespace name ‘MLAgents’ could not be found (are you missing a using directive or an assembly reference?
Anyone know whats going wrong?

1 Like

using Unity.MLAgents;

3 Likes

Thank you Ive been stuck on that for ages

I have this and I am still getting the error in console. Any advice? Thanks

B

@betike What’s the full error message? Did you follow the instructions here to install it from the pacakge manager? ml-agents/docs/Installation.md at release_8 · Unity-Technologies/ml-agents · GitHub

it was a path issue,its working now thanks

1 Like

How do you fix the Path issue? I met the same error: Assets\ML-Agents\Examples\Template\Scripts\TemplateAgent.cs(3,22): error CS0234: The type or namespace name ‘Actuators’ does not exist in the namespace ‘Unity.MLAgents’ (are you missing an assembly reference?)

Main problem is that current version of “ML-Agents package” in Unity doesn’t include “ML-Agents Extensions” which is used in example project
To fix this:
First instal Package from Unity Manager
Then you have to download current release version from git
After it you got 2 ways to install needed package:

  1. Instal using link to github
    In the Package Manager hit the “+” button, and select “Add package from git URL” (<- This one wont solve problem at the moment cause git owner has to accept your request)
    Place there:
    git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions
    Or in the your manifest.json file located in Project → Packages add next line below “com.unity.ml-agents”:
    “com.unity.ml-agents.extensions”: “git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions”,
  2. Local Instalation
    In the Package Manager hit the “+” button, and select “Add package from disk”
    Find “com.unity.ml-agents” in downloaded repo
    Select “package.json”
    Then same steps but with “com.unity.ml-agents.extensions” folder
    (After it you also may spot “UnityEditor.AsyncHTTPClient:smile:one(State, Int32)” error, it easily fixes by disabeling Edit → Preferences → Show Asset Store Search Hits )
8 Likes

It works by me! Thank you so much!

i have done both of the methods, but still get the same error. How?

I am also experiencing the same issue, every video that I watch does not address this. When I open up any of the example scrips from “Project” none of the ML Agent packages are being imported so the code doesn’t light up with any information.

1 Like

Hi @Kingsmen99 ,
I saw your post in the other thread. Can you provide more information like:

  • what operating system are you on and what version
  • what version of unity are you using
  • what code editor are you using
  • any other additional information about your installation process

It is easier to diagnose issues like this with more information.
Cheers,
Chris

Can u explain me how to do this? consider I’m a beginner.