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.
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.
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"]
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.
- Time-sliced raycast batches
- Deferred result gathering across frames
- Burst-compiled Unity jobs
- Live grid exposure visualization
- Runtime ray-budget slider
Requires Unity 2022.3.62f3.
- Open the project in Unity
- Open
Assets/Scenes/SampleScene.unity - Press Play
- Left-click a tile to move the actor
- Use the slider to adjust rays processed per frame