
unity-physics
Set up 3D physics in Unity 6.3 LTS: 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.
- Installs
- 6K
- Last 24h
- +315
- Trending rank
- #926
- Security
- Pass
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill unity-physics- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads unity-physics automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
Unity Physics (Rigidbody / PhysX)
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 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→PhysicsMaterialis a hard compile error in old code.
When to use
- Use when giving an object physical motion (forces, velocity, gravity), responding to collisions or triggers, setting up collision layers/masks, raycasting for ground checks or line-of-sight, or connecting bodies with joints.
- Use when scenes/prefabs contain
Rigidbody+Collidercomponents.
When not to use: 2D physics (Rigidbody2D, Collider2D) is a separate API — adapt the
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
- Add a
Rigidbodyto anything that should be simulated; add aColliderto anything 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. - Do all physics in
FixedUpdate. Read input inUpdate, store intent, then apply forces / setlinearVelocity/ callMovePositioninFixedUpdate. - Move bodies through the physics API, not the Transform. Use
AddForce,linearVelocity, orMovePosition— never assigntransform.positionto a non-kinematic Rigidbody (it teleports and breaks collision resolution). - Pick collision vs trigger. A solid collision blocks and calls
OnCollisionEnter; aColliderwithIs Triggerchecked passes through and callsOnTriggerEnter. - Organise interactions with layers. Put objects on layers and edit the Layer Collision Matrix (Project Settings → Physics) so unrelated things don't test against each other.
- Verify with the Physics Debugger (Window → Analysis → Physics Debugger) and by watching for jitter; if fast objects pass through walls, raise Collision Detection mode.
Patterns
1. Force-based movement in FixedUpdate (with a speed clamp)
using 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).
2. Collision vs trigger callbacks
// Solid hit: both have colliders, at least one has a dynamic (non-kinematic) Rigidbody.
private void OnCollisionEnter(Collision col)
{
// 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, 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);
}
3. Ground check with a layer-masked raycast
[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);
}
4. Kinematic platform that still pushes bodies
// 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));
Pitfalls
- Obsolete warnings on
velocity/drag/angularDrag— Unity 6 renamed them tolinearVelocity,linearDampingandangularDamping(angularVelocityis unchanged). Let the API Updater rename them or edit by hand;PhysicMaterialmust becomePhysicsMaterial. - Setting
transform.positionon a dynamic Rigidbody — teleports it, skips collision. UseMovePosition(kinematic/interpolated) or apply forces. If you do write the transform, physics queries (Raycast,OverlapSphere) see the old position until the next physics step — callPhysics.SyncTransforms()once before a same-frame query, never every frame. OnCollisionEnternever fires on aCharacterController—CharacterController.Movebypasses the Rigidbody system; it reports hits viaOnControllerColliderHit(ControllerColliderHit)instead. Don't add a Rigidbody to "fix" it — the two are mutually exclusive movement modes.- A ground or line-of-sight ray stops on a trigger volume —
Physics.Raycasthits trigger colliders by default (Project Settings → Physics → Queries Hit Triggers is on, i.e.Physics.queriesHitTriggers == true). PassQueryTriggerInteraction.Ignoreto skip them in one query, or turn the global setting off. A ray also returnsfalsefor 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
AddForcewake 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. CallRigidbody.WakeUp()on the affected bodies. - Applying forces in
Update— frame-rate-dependent and jittery. Physics goes inFixedUpdate. OnCollisionEnternever 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
Rigidbodyon 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
from
Discrete. NoteContinuoussweeps against static colliders only (it falls back to Discrete against other dynamic bodies);Continuous Dynamicalso sweeps against other continuous dynamic bodies;Continuous Speculativeworks against everything and is cheaper. For bullets, also consider aSphereCast/Raycastalong the trajectory instead of a collider. - Non-uniform-scaled
MeshColliders or scaled colliders misbehave; prefer primitive colliders and keep scale uniform. - A concave
MeshCollideron a moving body — Mesh colliders are concave by default, and 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 = 0stopsFixedUpdateand the simulation; queries read collider geometry and keep working. Restore a positivetimeScalewhen the pause ends. - Everything collides with everything — wasted cost; assign layers and prune the Layer Collision Matrix.
References
- For raycast variants (
SphereCast,RaycastAll,OverlapSphere,LayerMaskbit math) and joints (FixedJoint,HingeJoint,ConfigurableJoint, breakable joints), readreferences/raycasting-and-joints.md. - Primary docs: Unity Manual "Physics" section and
ScriptReference/Rigidbody,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 "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
physics-tuning— engine-agnostic feel: fixed timestep, mass/drag, CCD, stability.unity-csharp-scripting— theFixedUpdate/Updatesplit these patterns rely on.unity-navmesh— agent movement that is not force-driven.
FAQ
What does the unity-physics skill do?
Set up 3D physics in Unity 6.3 LTS: 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.
How do I install unity-physics?
Run npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill unity-physics in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/unity-physics/ (personal) or .claude/skills/unity-physics/ (project).
Which AI agents can use unity-physics?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is unity-physics safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains unity-physics?
It is published by gamedev-skills in gamedev-skills/awesome-gamedev-agent-skills. It has 5,954 recorded installs.
More from gamedev-skills/awesome-gamedev-agent-skills
game-feel
gamedev-skills/awesome-gamedev-agent-skills
Add "juice" and game feel that makes actions satisfying — screen shake, hit-stop/freeze frames, tweened/eased motion, squash & stretch, knockback, and layered audio-visual feedback — as engine-neutral techniques that pair with the detected engine's tween, particle, and camera APIs. Use when the user mentions game feel, juice, "make it feel good/punchy", screen shake, hit stop, screen freeze, easing, squash and stretch, impact frames, or feedback/polish on hits, jumps, pickups, and deaths.
game-ui-ux
gamedev-skills/awesome-gamedev-agent-skills
Design and build game UI/UX — HUDs, menus, and overlays — that survive every screen: anchor- based responsive layout, resolution/aspect scaling and safe areas, keyboard/gamepad focus navigation, a screen/menu state stack, and event-driven (not polled) HUD updates. Engine- neutral patterns that pair with the detected engine's UI skill. Use when the user mentions HUD, health bar, main menu, pause menu, settings screen, UI layout, anchors, UI scaling, aspect ratio, safe area, controller/keyboard menu navigation, or wiring UI to game state.
level-design
gamedev-skills/awesome-gamedev-agent-skills
Design and build playable levels — the blockout/whitebox-to-playable workflow, player metrics and grid layout, pacing and flow (tension/rest curve), gating and the critical path, and encounter design. Engine-neutral practice. Use when the user mentions level design, blockout/whitebox/greybox, level layout, level pacing, encounter design, or the critical path through a level.
performance-optimization
gamedev-skills/awesome-gamedev-agent-skills
Find and fix game performance problems methodically — measure with the engine profiler first, reason about the frame-time budget, locate the CPU-vs-GPU bottleneck, then apply the right fix: object pooling, draw-call batching, fewer allocations/GC spikes, and asset budgets. Engine- neutral method that pairs with each engine's profiler. Use when the user mentions performance, optimize, low/dropping FPS, frame drops, stutter, lag, profiler, frame budget, draw calls, batching, garbage collection/GC spikes, object pooling, or "the game runs slow".
game-ai
gamedev-skills/awesome-gamedev-agent-skills
Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A pathfinding — engine-neutral algorithms that pair with the detected engine's navigation API. Use when building enemy AI, an FSM or behavior tree, steering/flocking, or pathfinding, or when the user mentions state machine, behavior tree, blackboard, A, navmesh, seek, or patrol/chase.
audio-design
gamedev-skills/awesome-gamedev-agent-skills
Implement game audio practice — bus/mixer architecture and gain in decibels, ducking (sidechain), adaptive/dynamic music via layering and re-sequencing, SFX variation, and beat synchronization. Engine-neutral. Use when the user mentions audio mixing, audio buses, adaptive/dynamic music, ducking, SFX variation, music layers, or syncing gameplay to the beat.
Popular education & science skills
teach
mattpocock/skills
Teach the user a new skill or concept, within this workspace.
scaffold-exercises
mattpocock/skills
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
paper-context-resolver
lllllllama/rigorpilot-skills
Rigor Paper Context helper for README-first deep learning repo reproduction. Use only when the README and repository files leave a narrow reproduction-critical gap and the task is to resolve a specific paper detail such as dataset split, preprocessing, evaluation protocol, checkpoint mapping, or runtime assumption from primary paper sources while recording conflicts. Do not use for general paper summary, repo scanning, environment setup, command execution, title-only paper lookup, or replacing README guidance by default.
caveman-learn
juliusbrussee/caveman
Act on a Caveman learn report - review the ranked token sinks, apply cost-lowering fixes with per-edit consent, and report what those fixes returned. Use when asked to lower an agent's token cost, what caveman has saved, to trim a heavy CLAUDE.md, or to offload re-pasted context into cavemem.
gsap-plugins
greensock/gsap-skills
Official GSAP skill for GSAP plugins — registration, ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, SVG and physics plugins, CustomEase, EasePack, CustomWiggle, CustomBounce, GSDevTools. Use when the user asks about a GSAP plugin, scroll-to, flip animations, draggable, SVG drawing, or plugin registration.
teach-impeccable
pbakaus/impeccable
DEPRECATED: Use /impeccable teach instead. This command has been folded into the impeccable skill.