Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Async raycasts in Jobs

Discussion in 'Entity Component System' started by LennartJohansen, Mar 5, 2018.

  1. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi.

    In the roadmap for 2018.1 async Raycasts for jobs is listed.
    I know it is not included yet, but is there any info on how this will work?

    Will we be able to raycst in a Job? If this is the case how does the result data look? In the normal API you get a reference to the hit collider back. I guess that will not be possible in a different thread?

    Lennart
     
    Krajca likes this.
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Look at RaycastCommand it has a complete example. It acts more or less like a custom type of job, you run it via it's own schedule method alongside other jobs. So it's designed to be chained in with other jobs. The api is more or less like the non allocating physics api's. You pass it a NativeArray to store the results in.
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Thanks. I did not know that was in there already.
     
    antoripa likes this.
  4. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    any example?
     
  5. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361