Skip to content

zschzen/Unity-Deferred-Jobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Deferred Jobs

A Unity prototype for deferred visibility queries using the C# Job System, Burst, batched raycasts, and time slicing. It was built after studying Allen Chou's series on Delayed Result Gathering and Time Slicing.

Unity Burst

Actor scanning a grid while a runner navigates to the nearest hidden tile

Note

The exposure map is a test case only. The goal is to experiment with deferred gathering and time-slicing patterns, not to build a production visibility system.


Overview

An actor scans a grid using raycasts spread across frames. Results feed an exposure map that colors tiles and guides a runner toward the nearest hidden position.

flowchart LR
    Actor["Actor position"] --> Slice["Select ray slice"]
    Slice --> Setup["RaycastSetupJob"]
    Setup --> Batch["RaycastCommand.ScheduleBatch"]
    Batch --> Gather["RaycastGatherJob"]
    Gather --> Map["Exposure map"]
    Map --> Grid["Grid colors\nred = visible · green = hidden"]
    Map --> Runner["Runner finds nearest hidden tile"]
    Runner --> NavMesh["NavMeshAgent"]
Loading

Raycast scheduling and result gathering are deliberately separated by one or more frames, keeping the main thread free while the Job System and Burst handle the work.


Features

  • Time-sliced raycast batches
  • Deferred result gathering across frames
  • Burst-compiled Unity jobs
  • Live grid exposure visualization
  • Runtime ray-budget slider

Getting Started

Requires Unity 2022.3.62f3.

  1. Open the project in Unity
  2. Open Assets/Scenes/SampleScene.unity
  3. Press Play
  4. Left-click a tile to move the actor
  5. Use the slider to adjust rays processed per frame

Packages

About

Delayed result gathering and time slicing patterns for Unity's Job System

Topics

Resources

License

Stars

Watchers

Forks

Contributors