見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。
Create and fix Unity 2D physics
Do not weigh 3D physics options. If evidence shows the user means 3D, say so and stop.
Prefer WebFetch over WebSearch — faster and lands on the exact reference. Only fetch what you need. Replace <VERSION> with the following before fetching:
- docs.unity.com: The Unity version, e.g.
6000.7. Pages are markdown — URLs end in.md. - Package on docs.unity3d.com: The package version, e.g.
@1.1. CheckPackages/manifest.jsonif unsure.
Important
- Use the unity cli (
unity command --format json) and theunity-cliandunity-pipelineskills for each step. - Don't use
usingdirectives or unqualified types in thesnippetforeval. The compiler reads usingUnityEngineand a bare AssetDatabase, Volume, or Object causes errors (CS0246 / CS0103 / CS0104).returnwhat you want to read; it arrives atdata.result.result. - Create a restore point you can roll back to if your changes fail.
- Do only what's asked. Don't change unrelated assets or files.
- Avoid long explanations.
- Never leave verification code in the user's script; never build logging or settle-detection they didn't ask for. See Final step.
- Never reflect over types to discover an API — fetch the member page instead. The system probe is the one exception.
Step 0: Which physics system
Unity has two 2D physics systems. They share no code and never interact. Identify which one before writing any physics code — an answer from the wrong system compiles, runs, and does nothing.
Check the request, scene and existing scripts against the table below. Components are the reliable signal — check scene and existing scripts first. Check the user's request wording too: "add a collider" is component language, "spawn a thousand" is script language.
| Signal | System |
|---|---|
| Physics Pose, Area, Constraint or Simulation components | Core components, 6000.7+ with the package |
| Rigidbody 2D, Collider 2D, Joint 2D, Effector 2D | Legacy |
Unity.U2D.Physics or UnityEngine.LowLevelPhysics2D types in script | Core in script |
Rigidbody2D, Collider2D, Physics2D types | Legacy |
| Both present | Separate simulations. Say so, treat separately |
| No signal | Stop and ask, offering the three routes above |
Key:
- Legacy = Rigidbody 2D and Collider 2D components.
- Core components = Physics Pose and Physics Area, requiring
com.unity.2d.physicsand Unity 6000.7+. - Core in script =
Unity.U2D.PhysicsAPI, no package needed.
If still unsure which systems are installed, run the probe. If the route is still unknown, stop and ask — offer all three routes and never choose for the user:
Probe:
unity command eval --code 'var r = ""; foreach (var n in new[] { "UnityEngine.Rigidbody2D", "Unity.U2D.Physics.PhysicsWorld", "UnityEngine.LowLevelPhysics2D.PhysicsWorld", "Unity.U2D.Physics.PhysicsPose" }) { var f = false; foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies()) if (a.GetType(n) != null) f = true; r += f + ","; } return r;'The Probe returns: legacy present, Core as Unity.U2D.Physics, Core as UnityEngine.LowLevelPhysics2D, Core components present. Core exists if either Core value is true; the true one gives the namespace. false rules that route out.
System reference
Once you know the route, read the matching reference before acting:
- 2D Physics Core reference - components, configuring them, creating bodies in script, ownership, and the full Core topic map.
- Legacy 2D physics reference - the legacy manual topic map.
Worked examples
Prefer in order: the C# example on the type or member page you are using; existing project scripts (match their style); the sample project at https://github.com/Unity-Technologies/PhysicsExamples2D. Check all three before inventing a pattern.
Final step
Do the following checks:
- Check the project has zero console errors. Use
console_statusfor counts. - Stop there unless the user asked you to prove it works or you suspect a specific fault.
- If you do enter Play mode, do it once only to chase a fault you already suspect. Read the world through
evalrather than adding logging. Take no screenshots as they take too much time.
If a check fails, go back and reread the docs pages in the matching reference to find out what you missed.
Final report
Short checklist: what you changed and why, which physics system you used, anything left for the user to decide or do.

