Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Set up 3D physics in Unity 6: Rigidbody movement and forces, colliders, triggers vs collisions, layer-based collision, raycasts, and joints. Use when adding a Rigidbody, handling OnCollisionEnter/OnTriggerEnter, tuning collision layers, casting rays, or when the user mentions Unity physics, AddForce, isKinematic, or linearVelocity.
.claude/skills/gamedev-skills-unity-physics/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 81% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 58% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 47% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 153% | 0% |
Make objects move, collide, and detect each other with Unity 6.3 LTS's built-in 3D physics (PhysX). Get the FixedUpdate discipline, trigger-vs-collision rules, and collision layers right. Targets Unity 6.3 LTS (6000.3).
> Unity 6.3 LTS rename: Rigidbody.velocity is now Rigidbody.linearVelocity (the old > name is deprecated). Code copied from older tutorials will warn or fail to compile.
collisions or triggers, setting up collision layers/masks, raycasting for ground checks or line-of-sight, or connecting bodies with joints.
Rigidbody + Collider components.When not to use: 2D physics (Rigidbody2D, Collider2D) is a separate API — adapt the concepts but the types differ. Cross-engine feel tuning (timestep, jitter, tunnelling) → physics-tuning. Reading input that drives movement → unity-input-system.
Rigidbody to anything that should be simulated; add a Collider to anythingthat should be hit. A collision needs a Collider on both, and at least one Rigidbody.
FixedUpdate. Read input in Update, store intent, then applyforces / set linearVelocity / call MovePosition in FixedUpdate.
AddForce,linearVelocity, or MovePosition — never assign transform.position to a non-kinematic Rigidbody (it teleports and breaks collision resolution).
OnCollisionEnter; aCollider with Is Trigger checked passes through and calls OnTriggerEnter.
Matrix (Project Settings → Physics) so unrelated things don't test against each other.
for jitter; if fast objects pass through walls, raise Collision Detection mode.
FixedUpdate (with a speed clamp)csharpusing UnityEngine; [RequireComponent(typeof(Rigidbody))] public class Mover : MonoBehaviour { [SerializeField] private float accel = 30f, maxSpeed = 8f; private Rigidbody _rb; private Vector3 _input; // set from Update / input system private void Awake() => _rb = GetComponent<Rigidbody>(); private void FixedUpdate() { _rb.AddForce(_input * accel, ForceMode.Acceleration); // mass-independent accel // Unity 6.3 LTS: linearVelocity (was 'velocity'). Clamp horizontal speed. Vector3 flat = new(_rb.linearVelocity.x, 0, _rb.linearVelocity.z); if (flat.magnitude > maxSpeed) { flat = flat.normalized * maxSpeed; _rb.linearVelocity = new Vector3(flat.x, _rb.linearVelocity.y, flat.z); } } }
ForceMode: Force (continuous, mass-scaled), Acceleration (continuous, ignores mass), Impulse (instant, mass-scaled — jumps), VelocityChange (instant, ignores mass).
csharp// Solid hit: both have colliders, this one has a (non-kinematic) Rigidbody. private void OnCollisionEnter(Collision col) { Debug.Log($"Hit {col.gameObject.name} at {col.contacts[0].point}"); } // Overlap: one collider has 'Is Trigger' = true. Requires a Rigidbody on at least one party. private void OnTriggerEnter(Collider other) { if (other.CompareTag("Pickup")) Destroy(other.gameObject); }
csharp[SerializeField] private LayerMask groundMask; // set to your "Ground" layer in the Inspector private bool IsGrounded() { // Cast a short ray down; only test colliders on groundMask. return Physics.Raycast(transform.position, Vector3.down, out RaycastHit hit, 1.1f, groundMask); }
csharp// isKinematic Rigidbody: not driven by forces, but MovePosition interpolates and carries // resting bodies correctly (unlike moving the Transform directly). private void FixedUpdate() => _rb.MovePosition(_rb.position + Vector3.right * (2f * Time.fixedDeltaTime));
Rigidbody.velocity doesn't exist in Unity 6.3 LTS — use linearVelocity (andangularVelocity is unchanged).
transform.position on a dynamic Rigidbody — teleports it, skips collision.Use MovePosition (kinematic/interpolated) or apply forces.
Update — frame-rate-dependent and jittery. Physics goes inFixedUpdate.
Rigidbody on at least one of the twocolliders, and both colliders enabled; two static triggers don't report overlaps.
to Continuous (or Continuous Dynamic) for bullets/fast movers.
MeshColliders or scaled colliders misbehave; prefer primitivecolliders and keep scale uniform.
Collision Matrix.
SphereCast, RaycastAll, OverlapSphere, LayerMask bit math) andjoints (FixedJoint, HingeJoint, ConfigurableJoint, breakable joints), read references/raycasting-and-joints.md.
ScriptReference/Rigidbody,ScriptReference/Physics.Raycast.
physics-tuning — engine-agnostic feel: fixed timestep, mass/drag, CCD, stability.unity-csharp-scripting — the FixedUpdate/Update split these patterns rely on.unity-navmesh — agent movement that is not force-driven.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 15,957 | 9,537 | -40% | 1 | 1 | 0% | 3,206 | 3,518 | +10% | 0 | 0 | — |
case-02 | pass→pass | 15,484 | 20,188 | +30% | 1 | 1 | 0% | 2,979 | 5,403 | +81% | 0 | 0 | — |
case-03 | pass→pass | 11,821 | 10,746 | -9% | 1 | 1 | 0% | 2,246 | 3,554 | +58% | 0 | 0 | — |
case-04 | pass→pass | 10,061 | 6,833 | -32% | 1 | 1 | 0% | 2,004 | 2,942 | +47% | 0 | 0 | — |
case-05 | pass→pass | 5,247 | 5,909 | +13% | 1 | 1 | 0% | 1,058 | 2,678 | +153% | 0 | 0 | — |
case-06 | pass→pass | 7,140 | 6,595 | -8% | 1 | 1 | 0% | 1,346 | 2,858 | +112% | 0 | 0 | — |
case-07 | pass→pass | 5,002 | 4,469 | -11% | 1 | 1 | 0% | 1,011 | 2,429 | +140% | 0 | 0 | — |
case-08 | pass→pass | 8,154 | 5,326 | -35% | 1 | 1 | 0% | 1,394 | 2,581 | +85% | 0 | 0 | — |
case-09 | pass→pass | 8,720 | 9,735 | +12% | 1 | 1 | 0% | 1,688 | 3,373 | +100% | 0 | 0 | — |
case-10 | pass→pass | 7,909 | 5,464 | -31% | 1 | 1 | 0% | 1,537 | 2,652 | +73% | 0 | 0 | — |
case-11 | fail→fail | 7,535 | 3,855 | -49% | 1 | 1 | 0% | 1,356 | 2,288 | +69% | 0 | 0 | — |
case-12 | pass→pass | 9,111 | 7,987 | -12% | 1 | 1 | 0% | 1,549 | 3,148 | +103% | 0 | 0 | — |
case-13 | pass→pass | 5,014 | 3,857 | -23% | 1 | 1 | 0% | 909 | 2,306 | +154% | 0 | 0 | — |
case-14 | pass→pass | 11,416 | 9,417 | -18% | 1 | 1 | 0% | 2,228 | 3,392 | +52% | 0 | 0 | — |
case-15 | pass→pass | 3,567 | 4,098 | +15% | 1 | 1 | 0% | 594 | 2,288 | +285% | 0 | 0 | — |
case-16 | pass→pass | 3,499 | 2,783 | -20% | 1 | 1 | 0% | 504 | 1,986 | +294% | 0 | 0 | — |
case-17 | pass→pass | 15,755 | 15,233 | -3% | 1 | 1 | 0% | 2,866 | 3,950 | +38% | 0 | 0 | — |
case-18 | pass→pass | 9,976 | 8,712 | -13% | 1 | 1 | 0% | 2,092 | 3,252 | +55% | 0 | 0 | — |
case-19 | pass→pass | 10,225 | 8,852 | -13% | 1 | 1 | 0% | 1,804 | 3,093 | +71% | 0 | 0 | — |
case-20 | pass→pass | 9,909 | 9,234 | -7% | 1 | 1 | 0% | 1,979 | 3,438 | +74% | 0 | 0 | — |
case-21 | pass→pass | 10,729 | 10,785 | +1% | 1 | 1 | 0% | 2,161 | 3,732 | +73% | 0 | 0 | — |
case-22 | pass→pass | 8,593 | 7,685 | -11% | 1 | 1 | 0% | 1,685 | 2,927 | +74% | 0 | 0 | — |
case-23 | pass→pass | 18,582 | 17,226 | -7% | 1 | 1 | 0% | 3,439 | 4,867 | +42% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 8/3/2026 | +9% |
Other measured skills in the registry, with their headline benchmark lift.