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

RaycastCommands in a cycle

Discussion in 'Entity Component System' started by Eidoboy, Mar 22, 2018.

  1. Eidoboy

    Eidoboy

    Joined:
    Jul 3, 2012
    Posts:
    29
    I've created a NativeArray of RaycastCommands and results just like in the basic example. Now I need to process it in a cycle, in each iteration the raycasts' direction value changes. What is the best way, memorywise, to achieve this? Many thanks
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    If you need 5 iterations. You would schedule 5 raycast jobs and 5 jobs producing raycast command data. Basically you schedule jobs each iteration depending on each other...

    Code (CSharp):
    1.  
    2. JobHandle dependency;
    3. for (int i 0 ... 5)
    4.     dependency = prepareRaycastCommandsJob.Schedule(dependency);
    5.     dependency = ScheduleRaycastJob(dependency);
    6.  
     
    Eidoboy likes this.