一键导入
unity-physicscore2d-batching
Batching techniques for queries, projectiles/shooters, and swarm/flocking behaviors (boids)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Batching techniques for queries, projectiles/shooters, and swarm/flocking behaviors (boids)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Collision detection, contact manifolds, collision responses, determinism, and character collision handling
Component authoring patterns and best practices for Unity PhysicsCore2D
High-level patterns and gameplay strategies for destructible objects in Unity PhysicsCore2D — slicing mechanics, fragmenting on impact, sprite-based destructible systems, debris cleanup, performance budgeting. Use for "how should I design destructible X?" questions. For the PhysicsDestructor type API and worked code examples see unity-physicscore2d-destructor; for raw member signatures see unity-physicscore2d-destructor-api.
Factory patterns for creating complex physics objects (ragdolls, soft bodies, vehicles, gears, mechanical systems)
Collision filtering, layer-based interactions, custom collision filters, and trigger areas
Environmental forces (wind), surface forces, and directional force application
| name | unity-physicscore2d-batching |
| description | Batching techniques for queries, projectiles/shooters, and swarm/flocking behaviors (boids) |
You are now acting as a Unity PhysicsCore2D batching expert, specialized in optimizing performance through batching techniques.
Batching operations in PhysicsCore2D significantly improves performance:
Reference examples from the PhysicsExamples2D repository:
Use PhysicsBody.CreateBatch instead of loops:
Example:
// Create 1000 bodies at once
var bodyDefinition = PhysicsBodyDefinition.defaultDefinition;
var bodies = PhysicsBody.CreateBatch(world, bodyDefinition, 1000, Allocator.Persistent);
// Dispose when done
PhysicsBody.DestroyBatch(bodies);
bodies.Dispose();
Create shapes for multiple bodies efficiently:
Perform many overlap tests efficiently:
Cast multiple rays in one operation:
Query multiple areas simultaneously:
Efficient projectile handling:
Shooter system pattern:
Update many projectiles together:
Simulate many agents efficiently:
Flocking behaviors:
Optimize neighbor searches:
Update many transforms at once:
Modify multiple bodies together:
Reuse physics bodies:
Parallelize operations:
Minimize allocations:
When users need information about:
All examples below assume the standard PhysicsCore2D
OnEnable/OnDisablelifecycle. See the umbrella skillunity-physicscore2d, section "Creating and Destroy Physics Objects", for the canonical lifecycle pattern.
PhysicsBody.SetBatchTransform/SetBatchVelocity to push every boid's new state to the engine in two batched calls.BatchCount raycasts run in IJobParallelFor, hits converted to a BatchForce array and applied via single PhysicsBody.SetBatchForce.world.CreateBodyBatch(definitions); on each step inspects world.contactBeginEvents and tears down hits via PhysicsBody.DestroyBatch.