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

NavMeshWorld cannot be used in a job

Discussion in 'Entity Component System' started by Abbrew, Feb 3, 2022.

  1. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    I can't instantiate NavmeshQuery inside a ForEach. Here's the code
    Code (CSharp):
    1. Entities
    2.                .WithName("Calculating_path")
    3.                .WithAll<BehaviorProgressComponent>()
    4.                .WithReadOnly(translation)
    5.                .ForEach((Entity condition, int entityInQueryIndex, ref DynamicBuffer<ValidPathWaypointComponent> waypoints, ref BehaviorResultComponent result, in ValidPathQueryComponent query, in ValidPathPositionComponent position) =>
    6.                {
    7.                    var pathfinder = new NavMeshQuery(navMeshWorld, Allocator.Temp, NODE_ALLOCATION_AMOUNT);
    8.                })
    9.                .WithBurst()
    10.                .Schedule();
    The error messages are
    But if I try doing this
    Code (CSharp):
    1. .WithNativeDisableUnsafePtrRestriction(navMeshWorld)
    It doesn't work since NavMeshWorld itself is not a pointer, but the world inside of it is
     
  2. DrBoum

    DrBoum

    Joined:
    Apr 19, 2020
    Posts:
    26