Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

The type or namespace name `NavMeshSurface' could not be found.

Discussion in 'Scripting' started by elloPropello, Feb 27, 2018.

  1. elloPropello

    elloPropello

    Joined:
    Oct 7, 2013
    Posts:
    10
    Hi, I was looking at this tutorial (https://unity3d.com/de/learn/tutorials/topics/navigation/baking-navmesh-runtime) when I realized that the NavMeshSurface cannot be found.

    Am I missing something? I added using UnityEngine.AI and public NavMeshSurface[] surfaces; and it gives me the Error.

    Hope someone can help me. I am creating a procedural level out of a bunch of Prefabs (as walls) and a primitive plane as floor. So I guess I'll need to set the prefabs child cube meshes Navigation Static true and not Walkable. However untill the namespace issue isn't solved the rest won't make sense anyways.
     
    Last edited: Feb 27, 2018
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    EugeneVlasov likes this.
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,907
  4. elloPropello

    elloPropello

    Joined:
    Oct 7, 2013
    Posts:
    10
    GroZZler, actually I put them into a wrong folder. However, no I get a bunch of warnings about obsolete things. I'll see if i get it to work now. Thanks for pointing me to it

    LurkingNinjaDev, didn't think about this being the case
     
  5. elloPropello

    elloPropello

    Joined:
    Oct 7, 2013
    Posts:
    10
    ok... so now I got a general question. How would I add the instances created from the script to surfaces?
    for example in a loop i create walls:
    GameObject wall = (GameObject)Instantiate (Wall, pos, Quaternion.AngleAxis (0, Vector3.up));

    how can i add those wall objects to the NavMeshSurface[]?

    The tutorial talks about procedural levels but doesn't seem to show how to do it for real procedural level.
     
    Last edited: Feb 27, 2018
  6. elloPropello

    elloPropello

    Joined:
    Oct 7, 2013
    Posts:
    10
    ...nevermind, i think i was doing something totally stupid :D... now i am examining NavMeshModifier...
     
    Last edited: Feb 28, 2018
  7. kang630

    kang630

    Joined:
    Apr 12, 2020
    Posts:
    2
    How did you solve the problem, i have the same
     
  8. DJ_Design

    DJ_Design

    Joined:
    Mar 14, 2013
    Posts:
    122
    ..same issue, unity 2020
     
  9. ThomasSchoenbeck

    ThomasSchoenbeck

    Joined:
    Nov 1, 2019
    Posts:
    1
    TheDevloper likes this.
  10. Chris7899

    Chris7899

    Joined:
    Jul 19, 2020
    Posts:
    4
    1. install the package from the packagemanger through name or git-url.
    2. import the library in your script:
    using Unity.AI.Navigation;


    Solved it for me.
     
    seoli1225, Justice-V18 and darklass01 like this.
  11. QuarterMillion

    QuarterMillion

    Joined:
    Jul 18, 2020
    Posts:
    10
    Code (CSharp):
    1. using Unity.AI.Navigation;//???
    I can't seem to access it. It won't even let me do
    Code (CSharp):
    1. using Unity.AI;
    Am I missing something? And forget about installing it by github repository URL that didn't work either. Burst is the first subdirective I get there is no A-section for Unity. It starts with B.
     
  12. MonoFlux

    MonoFlux

    Joined:
    Jun 13, 2015
    Posts:
    39
    I could not find the reference Unity.AI.Navigation after installing the package. So I went to Package Manager settings in project settings and checked "Enable pre-release packages" in Package Manager settings. I then restarted my project.... and it worked! - Not sure if I needed to enable that setting, maybe restart was enough.
     
  13. CooperBVE

    CooperBVE

    Joined:
    Jan 1, 2022
    Posts:
    2
    Hopefully this might help someone, I had to import the AI Navigation package and then go to the Package Manager and download the samples of the package, scripts reloaded and I was able to use Unity.AI after this
     
  14. aliduyum

    aliduyum

    Joined:
    Nov 3, 2021
    Posts:
    1
    Thank you very much, I was gonna search it for weeks.
     
    CooperBVE likes this.
  15. TheAmazingB74

    TheAmazingB74

    Joined:
    Aug 28, 2015
    Posts:
    14
    I have done ALL of this. Adjusted project setting. Imported the navmesh components as well as the samples, and i STILL get missing namespace error.
     
  16. jacksonkr

    jacksonkr

    Joined:
    Jan 22, 2013
    Posts:
    22
    After downloading the code from github to my project:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.AI;
    3.  
    4. [RequireComponent(typeof(NavMeshSurface))]
    5. public class NavMeshTest : MonoBehaviour {
    6. // don't forget to build out class
    7. }
    etc etc
     
  17. Wappenull

    Wappenull

    Joined:
    Oct 29, 2013
    Posts:
    48
    I got the same error Upgrading 2022.1.15 to -> 2022.2.1
    Here is how I solve it:
    1. I was using the github (now deprecated) https://github.com/Unity-Technologies/NavMeshComponents
    2. If your project still had that, time to remove it. Unity already packed this thing in official package list. (via com.unity.ai.navigation)
    3. RESTART your editor once! Else assembly will not reload and editor wont see new namespace `
      Unity.AI.Navigation
      `
    4. After editor opened again, you would re-enter the safe mode due to script compile failure. Mine was complaining about missing `
      NavMeshSurface
      `
    5. Anywhere you have reference to `
      NavMeshSurface
      ` you would have something like `
      using UnityEngine.AI
      ` but it has moved, so using the new `
      using Unity.AI.Navigation;
      ` instead
    Now it's fine.
    upload_2022-12-24_22-57-17.png
     
    Fangh, Ch1ckenNug and kiddvmn like this.
  18. Ch1ckenNug

    Ch1ckenNug

    Joined:
    Sep 14, 2021
    Posts:
    8
    Thanks, this worked for me too. I guess that restarting fixed the issue.

    Also, for anyone wondering, here is the installation guide:
    https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html
     
    Wappenull likes this.