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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Seams bug in NavMeshQuery API with custom agentType

Discussion in 'AI & Navigation Previews' started by vitautart, Oct 27, 2018.

  1. vitautart

    vitautart

    Joined:
    May 3, 2018
    Posts:
    29
    When I try NavMeshQuery.BeginFindPath with custom agentType, I got error:
    ArgumentException: The start location doesn't belong to any active NavMesh surface.

    I created NavMeshLocation with query oreration, but it didn't work anyway with custom agentType, with default agentType (Humanoid) all works fine.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Experimental.AI;
    3. using UnityEngine.AI;
    4. using Unity.Collections;
    5.  
    6. public class Behavior : MonoBehaviour {
    7.  
    8.     NavMeshWorld world;
    9.     int agentID;
    10.     void Start () {
    11.  
    12.         agentID = GameObject.Find("Cube").GetComponent<NavMeshAgent>().agentTypeID;
    13.  
    14.         world = NavMeshWorld.GetDefaultWorld();
    15.         NavMeshQuery query = new NavMeshQuery(world, Unity.Collections.Allocator.Temp, 100);
    16.  
    17.         NavMeshLocation location = query.MapLocation(new Vector3(0, 0, 0), new Vector3(10, 10, 10), agentID);
    18.         NavMeshLocation end = query.MapLocation(new Vector3(5, 0, 5), new Vector3(10, 10, 10), agentID);
    19.         PathQueryStatus status = query.BeginFindPath(location, end);
    20.         int s;
    21.         query.UpdateFindPath(100, out s);
    22.         query.EndFindPath(out s);
    23.         NativeArray<PolygonId> slice = new NativeArray<PolygonId>(20, Allocator.Temp);
    24.         query.GetPathResult(slice);
    25.  
    26.         slice.Dispose();
    27.         query.Dispose();
    28.     }
    29. }
     
  2. adriant

    adriant

    Unity Technologies

    Joined:
    Nov 1, 2016
    Posts:
    54
    Hi! This is a bug that we've only recently become aware of. We'll fix it soon.
     
    Orimay and VildNinja like this.
  3. Danistmein

    Danistmein

    Joined:
    Nov 15, 2018
    Posts:
    75
    Hi, I have faced with same problem, has it been fixed in the last version?
     
  4. Whipexx_DigitalSun

    Whipexx_DigitalSun

    Joined:
    Aug 8, 2017
    Posts:
    16
    I've encountered this issue on 2020.1.5 (or a very similar one) and managed to isolate it in a small scene; since this has either not been fixed or appeared again; and I didn't see any active reports I've created a new one, you can track the progress here.
     
  5. victor_apihtin

    victor_apihtin

    Unity Technologies

    Joined:
    Mar 2, 2021
    Posts:
    28
    I am having this in 2021 (the year too)
     
  6. Whipexx_DigitalSun

    Whipexx_DigitalSun

    Joined:
    Aug 8, 2017
    Posts:
    16
  7. victor_apihtin

    victor_apihtin

    Unity Technologies

    Joined:
    Mar 2, 2021
    Posts:
    28
    My error was that Agent Type ID is not what I thought an index in "agents" list, but a hash value.
    Trying the number from the navmesh asset itself makes it work fine :)