Search Unity

Asynchronous raycasting and pathfinding

Discussion in '2018.1 Beta' started by MarekM2, Jan 10, 2018.

  1. MarekM2

    MarekM2

    Joined:
    Dec 9, 2013
    Posts:
    12
    Hi,
    I've just downloaded the new Unity (beta) 2018.1b version and I'm wondering how to use all the new fancyness introduced, like the two things mentioned in the topic. Can I just put pathfinding and raycasting code into IJob.Execute method definition and it will just work, or are there some more specialized structs I need to extend in order for those two to work (like IJobParallelForTransform)?
     
  2. adriant

    adriant

    Unity Technologies

    Joined:
    Nov 1, 2016
    Posts:
    31
    Hi,
    The existing NavMesh functionality cannot be used within IJobs. New methods for pathfinding, compatible with IJob, will be made available soon, in a beta release of Unity 2018.1. Scripting reference will be added to serve as entry point for learning about the new methods.
    Regarding raycasts in IJobs, they will be made available much later, in future versions of Unity.

    Later edit: Here I was referring to NavMesh raycasts.
     
    Last edited: Mar 9, 2018
  3. MarekM2

    MarekM2

    Joined:
    Dec 9, 2013
    Posts:
    12
    I guess you mean next beta release? (I'm already using 2018.1 beta)

    And as for the raycasting part - roadmap mentions it as a part of 2018.1 release, so by saying "future versions of Unity" do you mean some next beta, or, say, Unity 2019.1? :)
     
  4. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    56
    This is a bit disappointing, as the roadmap showed everything on track :/
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,772
    It will come during the 2018.1 beta period. Most likely in 18.1 beta 4.
     
  6. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,330
    This is great news :)
     
  7. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    908
    any example?
     
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,733
  9. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    908
  10. adriant

    adriant

    Unity Technologies

    Joined:
    Nov 1, 2016
    Posts:
    31
    Last edited: Mar 9, 2018
  11. element_wsc

    element_wsc

    Joined:
    Jul 27, 2012
    Posts:
    522
    Has anyone figured out how to do pathfinding with the new NavMeshQuery? I god to the point where you get the path result ( NativeSlice of PolygonIds ) and have no idea how to proceed further.
    Code (CSharp):
    1.  
    2. var start = query.MapLocation( currentPos, Vector3.one * 3f, 0 );
    3. var end = query.MapLocation( targetPos, Vector3.one * 3f, 0 );
    4.  
    5. var status = PathQueryStatus.Failure;
    6. status = query.BeginFindPath( start, end );
    7.  
    8. if (status != PathQueryStatus.InProgress)
    9.     return;
    10.  
    11. int performedIterations = 0;
    12. int maxIterations = 1024;
    13.  
    14.  do
    15.  {
    16.      int iterations;
    17.      status = query.UpdateFindPath( 32, out iterations );
    18.      performedIterations += iterations;
    19.  
    20.     if (status == PathQueryStatus.Failure || status == PathQueryStatus.OutOfNodes)
    21.         return;
    22.  
    23. } while (status != PathQueryStatus.Success && performedIterations < maxIterations);
    24.  
    25. int pathSize;
    26. status = query.EndFindPath( out pathSize );
    27. if (status == PathQueryStatus.Failure)
    28.     return;
    29.  
    30. var array = new NativeArray<PolygonId>( pathSize, Allocator.Temp);
    31. var path = new NativeSlice<PolygonId>( array );
    32. var nodeCount = query.GetPathResult( path );
     
    hadynlander and vanxining like this.
  12. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,488