What problem does it solve?
Individual per-body physics calls in Unity's PhysicsCore2D (Unity.U2D.Physics) create performance bottlenecks when simulating hundreds or thousands of bodies, projectiles, or agents. This Skill provides the batching patterns needed to replace loops of individual API calls with single batched operations.
Core Features & Use Cases
- Batch Body Creation and Destruction: Use
world.CreateBodyBatch and PhysicsBody.DestroyBatch to create and tear down many bodies in single calls with proper NativeArray disposal.
- Batched Queries and Forces: Run fans of raycasts in
IJobParallelFor jobs and apply results via PhysicsBody.SetBatchForce in one call.
- Swarm and Flocking Simulation: Implement Burst-compiled boid flocking with
SetBatchTransform and SetBatchVelocity to push thousands of kinematic agent states per frame.
- Use Case: Build a projectile shooter that spawns 100 bullets per volley via one
CreateBodyBatch call, then scans world.contactBeginEvents each step and destroys all hit projectiles with a single DestroyBatch call.
Quick Start
Ask the assistant to implement a batched boids flocking simulation or projectile shooter using Unity PhysicsCore2D batch APIs.