Custom jobs

Little Physics exposes three public system groups where you can plug in ECS systems, plus four job interfaces that schedule Burst-friendly work over native physics buffers. Together they let you read and modify simulation state at import, mid-step, and export without fighting the internal pipeline.

When to use what

Goal Hook Recommended API
Override ECS data before it enters native memory Import workflow — before internal import ECS components
Patch BodiesList or maps after import Import workflow — after internal import Native structures + PhysicsJobHandle
Apply forces, custom collision response, gameplay Inside the pipeline — LittlePhysicsUserSystemGroup Package job interfaces
Read native results before write-back Export workflow — before internal export Native structures
Sync to rendering, networking, or destroy entities Export workflow — after internal export ECS components

Prefer the package job interfaces inside the fixed-step loop. They iterate the correct buffers, respect ActiveBodiesCount, and chain PhysicsJobHandle through ScheduleAndChain. For raw IJob / IJobParallelFor work, combine dependencies manually — see Custom job interfaces.

Job interfaces

All four interfaces run in LittlePhysicsUserSystemGroup unless noted. Three are parallel over active bodies or collision slots; ILineCastJob uses a single helper thread.

Interface Iterates Parallel
IBodiesJob Every active body in BodiesList Yes
ICollisionJob Object-to-object collision slots in CollisionDataMap Yes
ISurfaceJob Surface contacts in SurfaceCollisionMap Yes
ILineCastJob Linecast hits against the spatial map No (single thread)

Prerequisites

Custom systems should:

  1. Gate on PhysicsReadyTag after bootstrap completes.
  2. Read simulation buffers from PhysicsStructuresComponent.
  3. Chain jobs through SimulationDataComponent.PhysicsJobHandle whenever you touch native memory outside the package interfaces.

Use LittlePhysicsTimeComponent.DeltaTime inside LittlePhysicsUserSystemGroup for the scaled substep delta (respects time scale and substeps).

Samples

The package All Samples import includes working custom-job examples:

Sample scene System Interface / group
Scene 4 — Trigger TriggerAttractionSystem ICollisionJob.IWriteBodies
Scene 5 — Linecast LineCastSystem ILineCastJob.IWriteBody
Scene 5 — Linecast LineCastInputSystem LittlePhysicsImportGroup (pre-import input)
Scene 3 — Pachinko DisappearAtYSystem LittlePhysicsExportGroup (post-export cleanup)

Table of contents


This site uses Just the Docs, a documentation theme for Jekyll.