Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Navmeshes in AR Foundation

Discussion in 'AR' started by JakHussain, Nov 5, 2018.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    I'm at a bit of a loss on how to get navmeshing working on the Planes detected by AR Foundation. I'm looking to set up an environment where I can detect my table and floor in AR, spawn a character on the table and use navmeshes to get the character to pathfind to the floor where they can jump down.

    This is super easy in a regular 3D scene but I don't even know where to begin with using AR Foundation. Any pointers?
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    One difference between AR and a "regular scene" is that you don't have the input geometry (i.e., the planes) during edit time, so you cannot create the nav meshes beforehand. You might want to check out this tutorial which shows you how to create nav meshes at runtime.
     
  3. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    63
    Hi @tdmowrer
    I have followed the tutorial you mentioned here and built navmesh runtime, but it does not seem to generate navmesh surface on the detected planes. The same code generates navmesh on a separate plane gameobject at runtime and my agent moves from its current position to the desired position covering the shortest distance.
    But when it comes to creating navmesh on the detected planes, it does not seem to do it as when I remove the dummy plane, my agent does not move an inch.

    My navmesh surface component looks like this:

    upload_2019-9-24_21-2-38.png

    And my navmesh agent component looks like this

    upload_2019-9-24_21-5-37.png

    I am using the AR default plane generated by unity without any change. Am I missing anything here? Look forward to your response.

    Regards.
     
  4. b9n

    b9n

    Joined:
    Feb 6, 2020
    Posts:
    14
    navmeshcomponents 2019.3 [arfoundation 4.0] worked like a charm
    Add an empty with LocalNavMeshBuilder.cs
    create an agent, copy config from an example scene, adjust arsessionorigin for proper scale
    Add "NavMeshSourceTag.cs" to the plane prefab
     
    Last edited: Jul 4, 2020
  5. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,077
    is there an up to date version of this tutorial
     
  6. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    978
    I used Unity's Swords and Shovel course to learn the Navigation, but it is unavailbale for now. May be you can find it on the internet somewhere.

    NavMeshSurface from this course was moved to AI navigation package.
    It's needed to move your navigation surface with all the ancestors in the scene, which gives you some freedom.

    Another way from Unity is that you can use arSessionOrigin.MakeContentAppearAt() in AR Foundation 4 (AR Foundation 5+ needed this file to use it) to move your AR Content to the right place in your scene.

    Using both of these tools (NavMeshSurface & arSessionOrigin.MakeContentAppearAt()) I could achieve the stable work of Navigation System with Plane Detection in my AR Shooter asset.

    These are the screenshots below with my settings of NavMeshSurface & NavMeshAgent, if ut can help you in any way.

    Screenshot 2023-12-06 at 16.58.37.png Screenshot 2023-12-06 at 16.39.28.png
     
    Last edited: Dec 6, 2023