Search Unity

UnityEngine.AI

Discussion in 'Getting Started' started by Fman, Jan 18, 2018.

  1. Fman

    Fman

    Joined:
    Apr 28, 2013
    Posts:
    6
    Hello.

    Been learning C# and Unity3D both same time and gotten pretty far, I'm surprised of myself to say the least.
    But just a simple question, don't hang me for this! <3
    Been following some tutorials etc.

    They use UnityEngine.AI in these tutorials, tried to google like crazy but can't find info, even from this site, so when I try to write up 'Using UnityEngine.AI', VisualStudio says that there is none named liked that.

    So is it included maybe in UnityEngine and I am just watching obsolete tutorials?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,887
    UnityEngine.AI is the parent class for NavMesh related classes, so it's used for moving Nav agents around a scene. I'm not sure why VS would be giving you errors... Did you open the script by double clicking it inside Unity? Opening it otherwise might not be linking the proper assemblies to provide Intellisense for Unity's built-in classes.
     
  3. Fman

    Fman

    Joined:
    Apr 28, 2013
    Posts:
    6
    Yes, opened through Unity by double clicking freshly made script, but it won't let me add UnityEngine.AI.
    VS says "The type or namespace name 'AI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)"
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,887
    Well when it comes down to it, it doesn't matter what Visual Studio thinks. It's the Unity compiler you have to please. So if you add the using directive at the top of the script, and VS has a problem, but the Unity editor doesn't, that's all that matters. It's annoying, for sure, and you'll have issues with autocomplete and such, but you can make it work.

    You may also consider trying Visual Studio Code. They have Unity tools for it that work great, and it's a much more lightweight option than full Visual Studio.
     
  5. Fman

    Fman

    Joined:
    Apr 28, 2013
    Posts:
    6
    Okay, thanks a lot!
    At least now I know, there is UnityEngine.AI and I don't have to overthink this further.
    I'll try that one out.
     
    Schneider21 likes this.
  6. Fman

    Fman

    Joined:
    Apr 28, 2013
    Posts:
    6
    If someone else ever has this problem, reinstall did it for me.
     
  7. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    2,887
    Awesome! Thanks for posting the solution!
     
    Fman likes this.
  8. Yunus_Sutanti

    Yunus_Sutanti

    Joined:
    Aug 28, 2019
    Posts:
    1
    I have the same problem and it's still doesn't work