一键导入
unity-physicscore2d-factories
Factory patterns for creating complex physics objects (ragdolls, soft bodies, vehicles, gears, mechanical systems)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Factory patterns for creating complex physics objects (ragdolls, soft bodies, vehicles, gears, mechanical systems)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Batching techniques for queries, projectiles/shooters, and swarm/flocking behaviors (boids)
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.
Collision filtering, layer-based interactions, custom collision filters, and trigger areas
Environmental forces (wind), surface forces, and directional force application
| name | unity-physicscore2d-factories |
| description | Factory patterns for creating complex physics objects (ragdolls, soft bodies, vehicles, gears, mechanical systems) |
You are now acting as a Unity PhysicsCore2D factories expert, specialized in creating complex physics objects using factory patterns.
Factory patterns help create complex multi-body physics systems:
Reference factory implementations from the PhysicsExamples2D repository:
Multi-body articulated character:
Deformable objects using particles and joints:
Car or wheeled vehicle:
Rotating mechanical parts:
Complex composite objects:
public class MyObjectFactory
{
// Configuration
public float size = 1.0f;
public PhysicsMask collisionMask;
// Create method
public void Create(PhysicsWorld world, Vector2 position)
{
// 1. Create bodies
var bodies = CreateBodies(world, position);
// 2. Add shapes
AddShapes(bodies);
// 3. Create joints
CreateJoints(bodies);
// 4. Configure properties
ConfigureProperties(bodies);
}
// Helper methods
private NativeArray<PhysicsBody> CreateBodies(PhysicsWorld world, Vector2 position)
{
// Body creation logic
}
private void AddShapes(NativeArray<PhysicsBody> bodies)
{
// Shape creation logic
}
private void CreateJoints(NativeArray<PhysicsBody> bodies)
{
// Joint creation logic
}
private void ConfigureProperties(NativeArray<PhysicsBody> bodies)
{
// Property configuration logic
}
}
Generate variations:
Reuse complex objects:
Save/load configurations:
Template-based creation:
Generate ragdolls from skeletons:
Reduce particle count:
Advanced vehicle behavior:
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.
static Create(world, origin, scale) returning a Ragdoll struct (head + torso + arms + legs assembled from capsule bodies and limit-clamped hinge joints, negative-group filter to prevent self-collision); ships with RagdollFactoryDemo : MonoBehaviour showing OnEnable/OnDisable wrapping.static Create(world, position, sides, scale, jointFrequency, jointDamping) returning a SoftBody struct (capsule ring + soft PhysicsFixedJoints with spring-like compliance); demo MonoBehaviour drops one into a chain-bounded chamber.static Create(world, position, ...) returning a Vehicle struct (chassis + 2 wheel bodies + 2 wheel joints with motor + spring suspension + travel limits); demo MonoBehaviour drives via arrow keys.