What problem does it solve?
Building complex 2D collision shapes from simple primitives in Unity's PhysicsCore2D API requires correct use of PhysicsComposer boolean operations, allocator management, and shape attachment, where mistakes cause leaked native memory, discarded geometry, or wrong output shapes.
Core Features & Use Cases
- Boolean Geometry Composition: Combine CircleGeometry, CapsuleGeometry, PolygonGeometry, and raw vertex spans using OR, AND, NOT, and XOR operations with explicit layer ordering.
- Polygon and Chain Output: Generate filled convex polygon decompositions via CreatePolygonGeometry or hollow edge-only collision via CreateChainGeometry, then attach results with CreateShapeBatch or CreateChain.
- Job-Safe Workflows: Use PhysicsComposer inside Burst-compiled jobs with Allocator.TempJob while respecting main-thread body creation constraints.
- Use Case: Create a donut-shaped collider by adding a large outer circle as the base layer, subtracting a smaller inner circle with NOT, generating the polygon geometry, and attaching it to a dynamic body with CreateShapeBatch.
Quick Start
Ask the AI to create a Unity PhysicsCore2D script that combines a box and two circles with PhysicsComposer boolean operations and attaches the resulting polygons to a physics body.