Search Unity

Resolved Invalid AABB result on NavMeshQuery.MapLocation

Discussion in 'Entity Component System' started by wbourassabennett, May 21, 2021.

  1. wbourassabennett

    wbourassabennett

    Joined:
    Apr 24, 2020
    Posts:
    16
    I'm messing around with using the Navmesh and NavMeshQuery in DOTS. I have a few entities moving around on the terrain, but at some points (it seems to often happen on steep terrain) the entity's translation is set to (NaN, NaN, NaN) after the console throws this error:

    Code (JavaScript):
    1.  
    2. Invalid AABB result
    3. UnityEngine.Experimental.AI.NavMeshQuery:MapLocation (UnityEngine.Vector3,UnityEngine.Vector3,int,int)
    4. Navigation_System/<>c__DisplayClass_OnUpdate_LambdaJob1:OriginalLambdaBody (Navigator_Data&,Unity.Entities.DynamicBuffer`1<NavWaypoints_Buffer>&,Unity.Entities.DynamicBuffer`1<NavStatus_BufferElement>&,Emission_Property&,Unity.Transforms.Translation&,Unity.Entities.Entity&,ObstacleAvoidance_Data&) (at Assets/Scripts/_Systems/Navigation_System.cs:68)
    5. Navigation_System/<>c__DisplayClass_OnUpdate_LambdaJob1:PerformLambda (void*,void*,Unity.Entities.Entity)
    6. Unity.Entities.CodeGeneratedJobForEach.StructuralChangeEntityProvider:IterateEntities (void*,void*,Unity.Entities.CodeGeneratedJobForEach.StructuralChangeEntityProvider/PerformLambdaDelegate) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/CodeGeneratedJobForEach/LambdaParameterValueProviders.cs:352)
    7. Navigation_System/<>c__DisplayClass_OnUpdate_LambdaJob1:Execute (Unity.Entities.ComponentSystemBase,Unity.Entities.EntityQuery)
    8. Navigation_System:OnUpdate () (at Assets/Scripts/_Systems/Navigation_System.cs:53)
    9. Unity.Entities.SystemBase:Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/SystemBase.cs:400)
    10. Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:472)
    11. Unity.Entities.ComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:417)
    12. Unity.Entities.ComponentSystem:Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystem.cs:114)
    13. Unity.Entities.ScriptBehaviourUpdateOrder/DummyDelegateWrapper:TriggerUpdate () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ScriptBehaviourUpdateOrder.cs:333)
    14.  

    I have no idea what the Invalid AABB result means in this case and/or how to avoid it, if it's a bug or if I am doing something wrong.

    Here's a piece of the code that I wrote that is relevent
    Code (CSharp):
    1.  
    2. public class Navigation_System : SystemBase
    3. {
    4.     public Dictionary<Entity, NavMeshQuery> navQueries = new Dictionary<Entity, NavMeshQuery>();
    5.  
    6.     protected override void OnUpdate()
    7.     {
    8.         Entities.ForEach((ref Navigator_Data nav, ref Translation trans, in Entity entity) =>
    9.         {
    10.             NavMeshLocation location = navQueries[entity].MapLocation(trans.Value, new float3(5, 5, 5), nav.agentID, nav.areaMask); // line 68
    11.             trans.Value = location.position;
    12.  
    13.         }).WithoutBurst().WithStructuralChanges().Run();
    14.     }
    15. }
    16.  
    It's also not an exception so I can't figure out how to debug this. There doesn't seem to be any useful information on what the error message is.

    If someone can help me figure out what this is / means and how to avoid it that would be helpful!

    Thanks!
     
  2. wbourassabennett

    wbourassabennett

    Joined:
    Apr 24, 2020
    Posts:
    16
    I managed to find out that somehow the NavMeshLocation's position provided by the query was (NaN, NaN, NaN), which in the following frame after setting the translation value would trigger the error.