Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(unity): physics queries hit triggers by default, Unity 6 renames, kinematic contact pairs

Kiro Crewfa8fb38b9841
diff --git a/skills/unity/unity-physics/SKILL.md b/skills/unity/unity-physics/SKILL.md
index 227a4d3..f7ab068 100644
--- a/skills/unity/unity-physics/SKILL.md
+++ b/skills/unity/unity-physics/SKILL.md
@@ -13,8 +13,10 @@ Make objects move, collide, and detect each other with Unity 6.3 LTS's built-in
(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.
+> **Unity 6 renames:** `Rigidbody.velocity` → **`linearVelocity`**, `drag` → **`linearDamping`**,
+> `angularDrag` → **`angularDamping`**. The old names still compile in 6.3 LTS but are obsolete
+> (warnings; the API Updater offers the rename), so write the new names. `PhysicMaterial` →
+> **`PhysicsMaterial`** is a hard compile error in old code.
## When to use
@@ -24,13 +26,17 @@ right. Targets **Unity 6.3 LTS (6000.3)**.
- Use when scenes/prefabs contain `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) →
+concepts but the types differ. Unity 6.3 also has a separate low-level 2D API
+(`UnityEngine.LowLevelPhysics2D`: `PhysicsWorld`, `PhysicsBody`) with its own isolated worlds;
+it is not the `Rigidbody2D` system. Cross-engine *feel* tuning (timestep, jitter, tunnelling) →
`physics-tuning`. Reading input that drives movement → `unity-input-system`.
## Core workflow
1. **Add a `Rigidbody`** to anything that should be simulated; add a `Collider` to anything
- that should be hit. A collision needs a `Collider` on both, and at least one `Rigidbody`.
+ that should be hit. `OnCollision*` messages need a Collider on both and at least one
+ **dynamic** (non-kinematic) Rigidbody: with the default Contact Pairs Mode, kinematic vs
+ kinematic and kinematic vs static send no collision messages.
2. **Do all physics in `FixedUpdate`.** Read input in `Update`, store intent, then apply
forces / set `linearVelocity` / call `MovePosition` in `FixedUpdate`.
3. **Move bodies through the physics API, not the Transform.** Use `AddForce`,
@@ -79,13 +85,15 @@ public class Mover : MonoBehaviour
### 2. Collision vs trigger callbacks
```csharp
-// Solid hit: both have colliders, this one has a (non-kinematic) Rigidbody.
+// Solid hit: both have colliders, at least one has a dynamic (non-kinematic) Rigidbody.
private void OnCollisionEnter(Collision col)
{
- Debug.Log($"Hit {col.gameObject.name} at {col.contacts[0].point}");
+ // GetContact avoids the garbage that the col.contacts array allocates.
+ Debug.Log($"Hit {col.gameObject.name} at {col.GetContact(0).point}");
}
-// Overlap: one collider has 'Is Trigger' = true. Requires a Rigidbody on at least one party.
+// Overlap: one collider has 'Is Trigger' = true, and at least one party has a Rigidbody
+// (or a Rigidbody carries the trigger). Two static colliders never report.
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Pickup")) Destroy(other.gameObject);
@@ -115,8 +123,9 @@ private void FixedUpdate() => _rb.MovePosition(_rb.position + Vector3.right * (2
## Pitfalls
-- **`Rigidbody.velocity` doesn't exist in Unity 6.3 LTS** — use `linearVelocity` (and
- `angularVelocity` is unchanged).
+- **Obsolete warnings on `velocity` / `drag` / `angularDrag`** — Unity 6 renamed them to
+ `linearVelocity`, `linearDamping` and `angularDamping` (`angularVelocity` is unchanged). Let
+ the API Updater rename them or edit by hand; `PhysicMaterial` must become `PhysicsMaterial`.
- **Setting `transform.position` on a dynamic Rigidbody** — teleports it, skips collision.
Use `MovePosition` (kinematic/interpolated) or apply forces. If you *do* write the transform,
physics queries (`Raycast`, `OverlapSphere`) see the old position until the next physics step
@@ -124,16 +133,21 @@ private void FixedUpdate() => _rb.MovePosition(_rb.position + Vector3.right * (2
- **`OnCollisionEnter` never fires on a `CharacterController`** — `CharacterController.Move`
bypasses the Rigidbody system; it reports hits via `OnControllerColliderHit(ControllerColliderHit)`
instead. Don't add a Rigidbody to "fix" it — the two are mutually exclusive movement modes.
-- **`Physics.Raycast` ignores triggers by default** — a ray won't report a trigger collider
- unless you pass `QueryTriggerInteraction.Collide` (or flip the global `Physics.queriesHitTriggers`
- / Project Settings → Physics → Queries Hit Triggers). It also returns `false` when the ray
- origin starts *inside* the target collider.
+- **A ground or line-of-sight ray stops on a trigger volume** — `Physics.Raycast` hits trigger
+ colliders by default (Project Settings → Physics → Queries Hit Triggers is on, i.e.
+ `Physics.queriesHitTriggers == true`). Pass `QueryTriggerInteraction.Ignore` to skip them in
+ one query, or turn the global setting off. A ray also returns `false` for a collider its
+ origin starts *inside*.
- **A resting Rigidbody stays put after you move or disable what it rests on** — below the
Sleep Threshold a body goes to sleep. Collisions and `AddForce` wake it automatically, but
moving a *static* collider (no Rigidbody) via its Transform may not, so the crate hangs in
mid-air when the floor slides away. Call `Rigidbody.WakeUp()` on the affected bodies.
- **Applying forces in `Update`** — frame-rate-dependent and jittery. Physics goes in
`FixedUpdate`.
+- **`OnCollisionEnter` never fires between two kinematic bodies** (or kinematic vs static) —
+ with the default Contact Pairs Mode, Unity only sends collision messages when at least one
+ body is dynamic. Make one dynamic, use a trigger, or set Project Settings → Physics →
+ Contact Pairs Mode to enable kinematic pairs (more contact work every step).
- **Trigger callbacks never fire** — triggers need a `Rigidbody` on at least one of the two
colliders, and both colliders enabled; two static triggers don't report overlaps.
- **Fast objects pass through walls (tunnelling)** — raise the Rigidbody's Collision Detection
@@ -147,6 +161,11 @@ private void FixedUpdate() => _rb.MovePosition(_rb.position + Vector3.right * (2
concave ones can only be static or kinematic; two concave colliders never collide at all.
For a dynamic Rigidbody enable **Convex** on the MeshCollider, or build a compound collider
from primitives.
+- **Part of a compound body drifts off on its own** — a compound collider should have exactly
+ one Rigidbody, on the root. An extra Rigidbody on a child makes that child a separate body.
+- **Nothing moves and no callbacks fire, but raycasts still hit** — `Time.timeScale = 0` stops
+ `FixedUpdate` and the simulation; queries read collider geometry and keep working. Restore
+ a positive `timeScale` when the pause ends.
- **Everything collides with everything** — wasted cost; assign layers and prune the Layer
Collision Matrix.
@@ -159,8 +178,9 @@ private void FixedUpdate() => _rb.MovePosition(_rb.position + Vector3.right * (2
`ScriptReference/Physics.Raycast`. For the added gotchas: `ScriptReference/CollisionDetectionMode`,
`ScriptReference/Physics-queriesHitTriggers`, `ScriptReference/MonoBehaviour.OnControllerColliderHit`,
`ScriptReference/Physics.SyncTransforms`, `ScriptReference/Rigidbody.WakeUp`, and the Manual
- pages "Introduction to rigid body physics" (sleeping) and "Introduction to Mesh colliders"
- (concave vs convex).
+ pages "Physics settings" (Queries Hit Triggers, Contact Pairs Mode), "Introduction to rigid
+ body physics" (sleeping), "Introduction to compound colliders" and "Introduction to Mesh
+ colliders" (concave vs convex).
## Related skills
diff --git a/skills/unity/unity-physics/references/raycasting-and-joints.md b/skills/unity/unity-physics/references/raycasting-and-joints.md
index 253e505..c59d957 100644
--- a/skills/unity/unity-physics/references/raycasting-and-joints.md
+++ b/skills/unity/unity-physics/references/raycasting-and-joints.md
@@ -40,8 +40,9 @@ Tips:
- `RaycastHit.normal` is the surface normal at the hit — use it to align decals or compute
slope angle (`Vector3.Angle(hit.normal, Vector3.up)`).
- Prefer the `NonAlloc` / buffer overloads in per-frame code to avoid garbage.
-- A ray starting *inside* a collider does not report that collider unless
- `Physics.queriesHitBackfaces` / start outside it.
+- A ray starting *inside* a collider never reports that collider; start the ray outside it.
+ (`Physics.queriesHitBackfaces` is a different setting: it only lets queries hit back-face
+ triangles of mesh colliders.)
## Joints