Search Unity

Properly use NavMeshQuery

Discussion in 'Entity Component System' started by Ylly, Dec 8, 2018.

  1. Ylly

    Ylly

    Joined:
    May 15, 2015
    Posts:
    24
    Hi there. I have a lot of units an army with formations and want them move on navmesh. I tried look into Nordeus demo , but got more questions. So what better way? Should i use NavMeshQuery per formation or per unit or some another division. Why NavMeshQuery used in Job and not parallel Job? How can i use it at all

    Like this:


    Code (CSharp):
    1.  
    2. public void Execute(int index)
    3. {
    4.        var start = NavMeshQuery.MapLocation(UnitPositionComponentArray[index].Value, Vector3.one * 0.5f, 0);
    5.        var end = NavMeshQuery.MapLocation(MinionPathDataArray[index].TargetPosition, Vector3.one * 0.5f, 0);
    6.        var status = NavMeshQuery.BeginFindPath(start, end);
    7.  
    8.        NavMeshQuery.UpdateFindPath(256, out int performed);
    9.  
    10.        status = NavMeshQuery.EndFindPath(out int polySize);
    11.  
    12.        var poligons = new NativeArray<PolygonId>(polySize, Allocator.Temp);
    13.        NavMeshQuery.GetPathResult(poligons);
    14.  
    15. }
    Checking "status" and use "end" like a target point for units? And there is another way when you just use NavMeshAgent where set target and Unit walk themself to target. So i got this "end" point and should use some MovementSystem and move units with my own system to target? And if its way how units will avoid objects and e.t.c. ?
     
  2. Ylly

    Ylly

    Joined:
    May 15, 2015
    Posts:
    24
    Any tips?