一键导入
unity-physicscore2d-components
Component authoring patterns and best practices for Unity PhysicsCore2D
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Component authoring patterns and best practices for Unity PhysicsCore2D
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | unity-physicscore2d-components |
| description | Component authoring patterns and best practices for Unity PhysicsCore2D |
This sub-skill provides detailed information about authoring Unity components that wrap PhysicsCore2D objects.
The PhysicsCore2D is an API that is decoupled from Unity GameObject and Components however it is designed to be used in two ways:
To make component authoring easier, the API has many features which make this easier such as:
A complete example package is available which wraps all the available physics objects into Unity components, all of which demonstrate the above features. The package can be found here: https://github.com/Unity-Technologies/PhysicsExamples2D/tree/master/Packages/com.unity.2d.physics.extras The package runtime directory contains all the Unity components available. All the example components begin with the prefix "Scene" i.e. SceneWorld, SceneBody, SceneShape etc.
The debug drawing refers to the PhysicsWorld renderer which will automatically draw the world contents (PhysicsBody, PhysicsShape, PhysicsJoint etc). The user can also explicitly ask for custom drawing on any PhysicsWorld to draw any geometry type, lines, line-strips, points, capsules, circles, boxes etc.
To control what is drawn in the world, use the world.drawOptions property (get/set). This property accepts an enumeration of things that should be drawn.
You can find the API reference for drawOptions here: https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Unity.U2D.Physics.PhysicsWorld-drawOptions.html
Best Practice: Individual components should NOT modify world.drawOptions as this is a global world-level setting. The user controls what is drawn at the world/scene level. If a component wants to conditionally draw something (like a circle, line, etc.), it should use a local boolean field (e.g., public bool DrawCircle = true) to control whether that specific component draws, not modify the global world settings.
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.
Batching techniques for queries, projectiles/shooters, and swarm/flocking behaviors (boids)
Collision detection, contact manifolds, collision responses, determinism, and character collision handling
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