unity-physics
БесплатноБез исполняемых скриптовНе проверенUnity 6.3 LTS physics in 3D and 2D: Rigidbody and Rigidbody2D, forces and linearVelocity, the layer collision matrix and raycasts. Use when an object falls…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
Unity Physics (3D PhysX and 2D)
Make objects move, collide and detect each other in Unity 6.3 LTS (6000.3). Unity has two
separate physics engines: 3D (Rigidbody, Collider, Physics) and 2D (Rigidbody2D,
Collider2D, Physics2D). They never interact: a Rigidbody2D falls straight through a
BoxCollider, and 3D callbacks never fire on 2D objects.
When to use
- Giving an object physical motion, responding to collisions or triggers, setting up layers, ray or shape casts for ground checks and line of sight, joints, kinematic movers.
- The project's scenes or prefabs contain
Rigidbody/ColliderorRigidbody2D/Collider2D.
When not to use: cross-engine feel (fixed timestep choice, jitter strategy, tunnelling
trade-offs) → physics-tuning; Tilemap Collider 2D and composite merging →
unity-tilemap-2d; pathfinding agents → unity-navmesh; reading the input that drives
movement → unity-input-system. If Unity's official fix-3d-physics-collisions or
create-2d-physics skill is installed and an Editor is connected, it can drive the Editor for
scene setup; this skill still owns the API and the code.
Workflow
- Find out which engine the object uses before touching code. Grep the scene or prefab
YAML for a
Rigidbody2D:orRigidbody:document header (andBoxCollider2D:vsBoxCollider:). Mixed 2D and 3D components on interacting objects are a bug, not a design. - Read the physics settings as text, not through the Inspector. 3D settings live in
ProjectSettings/DynamicsManager.asset(m_QueriesHitTriggers,m_ContactPairsMode,m_LayerCollisionMatrix), 2D settings inProjectSettings/Physics2DSettings.asset(m_QueriesHitTriggers,m_QueriesStartInColliders,m_SimulationMode,m_LayerCollisionMatrix). The matrix is a hex bitfield: read and change it withPhysics.GetIgnoreLayerCollision/IgnoreLayerCollision(2D: thePhysics2Dversions) rather than editing the hex. - Do physics in
FixedUpdate. Read input inUpdate, store intent, apply forces or setlinearVelocityor callMovePositioninFixedUpdate. Both engines step afterFixedUpdateby default. - Move bodies through the physics API, not the Transform.
AddForce,linearVelocity,MovePosition. Writingtransform.positionon a dynamic body teleports it and skips collision resolution. - Pick collision vs trigger. A solid collider blocks and calls
OnCollisionEnter(OnCollisionEnter2D);isTriggerpasses through and callsOnTriggerEnter(OnTriggerEnter2D). At least one of the pair needs a rigidbody. - Prune layer pairs that never need to touch. A runtime
IgnoreLayerCollisioncall is not saved; for a lasting change ask the user to untick the pair in Project Settings > Physics (or Physics 2D) > Layer Collision Matrix. The Unity CLI'ssettings.physics setdoes not cover the matrix (it sets gravity, solver iterations and bounce threshold only). - Verify with one of the checks below, then remove any temporary logging.
Patterns
1. Force-based movement in FixedUpdate with a speed clamp (3D)
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
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 and Acceleration are continuous (mass-scaled vs not); Impulse and
VelocityChange are instant (mass-scaled vs not; use them for jumps).
2. Ground check that ignores triggers (3D)
[SerializeField] private LayerMask groundMask; // only the Ground layer
private bool IsGrounded() =>
Physics.Raycast(transform.position, Vector3.down, out RaycastHit _, 1.1f,
groundMask, QueryTriggerInteraction.Ignore);
3. Kinematic platform that carries resting bodies (3D)
// isKinematic Rigidbody: MovePosition moves it through the solver, so bodies on top ride along.
private void FixedUpdate() =>
_rb.MovePosition(_rb.position + Vector3.right * (2f * Time.fixedDeltaTime));
2D physics (Rigidbody2D)
Same rules, different types. The traps a 3D habit walks into:
| 3D | 2D equivalent | Difference that bites |
|---|---|---|
Rigidbody.isKinematic |
Rigidbody2D.bodyType (Dynamic, Kinematic, Static) |
Rigidbody2D.isKinematic is obsolete; set bodyType |
OnCollisionEnter(Collision) |
`OnCollisionEnter2D(Co |
Установить unity-physics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл unity-physics?
Unity 6.3 LTS physics in 3D and 2D: Rigidbody and Rigidbody2D, forces and linearVelocity, the layer collision matrix and raycasts. Use when an object falls through the floor, OnTriggerEnter never fires, or a ground ray hits the player. Not for engine-neutral tunnelling tuning (`physics-tuning`), tilemap colliders (`unity-tilemap-2d`) or NavMesh (`unity-navmesh`).
Как установить скилл unity-physics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл unity-physics запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic