Search Unity

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:
    52
    Hi! This is a bug that we've only recently become aware of. We'll fix it soon.
     
    Orimay and VildNinja like this.
  3. wechat_os_Qy0_X1ITy6VrZHYPJFd58JGlA

    wechat_os_Qy0_X1ITy6VrZHYPJFd58JGlA

    Joined:
    Nov 15, 2018
    Posts:
    74
    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:
    11
    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

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

    Whipexx_DigitalSun

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

    victor_apihtin

    Joined:
    Mar 2, 2021
    Posts:
    26
    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 :)
     
unityunity