unity-physics-sh-t9p516
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "unity-physics-sh-t9p516" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-05e2dcaf4239ffcbaea3006556e51c7677f77bb5360722d753aea2dff83ea141. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/unity-physics-sh-t9p516 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Skill for the Unity physics engine that helps an AI agent efficiently perform tasks and operations related to Unity physics.
Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Make objects move, collide, and detect each other with Unity 6's built-in 3D physics (PhysX). Get the `FixedUpdate` discipline, trigger-vs-collision rules, and collision layers right. Targets **Unity 6 (6000.0 LTS)**.
- Audience
- 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` + `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`.
- Testing
- Not tested
Browse files
Frontmatter
name: Unity物理引擎
slug: unity-physics
version: 1.0.0
displayName: Unity物理引擎
description: >
Unity物理引擎专用技能,帮助AI Agent高效完成相关任务。
summary: "Unity物理引擎专用技能,帮助AI Agent高效完成相关任务。"
license: Apache-2.0
category: 游戏开发
framework:
- Claude Code
- Codex
- Hermes Agent
- OpenClaw
- QClaw
- WorkBuddy
platform: multi-platform
homepage: "https://github.com/1991513ccie-png"
repository: "https://github.com/1991513ccie-png"Unity Physics (Rigidbody / PhysX)
Make objects move, collide, and detect each other with Unity 6's built-in 3D physics
(PhysX). Get the FixedUpdate discipline, trigger-vs-collision rules, and collision layers
right. Targets Unity 6 (6000.0 LTS).
Unity 6 rename:
Rigidbody.velocityis nowRigidbody.linearVelocity(the old name is deprecated). Code copied from older tutorials will warn or fail to compile.
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. 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. A collision needs aCollideron both, and at least oneRigidbody. - 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: 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, 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);
}
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
Rigidbody.velocitydoesn't exist in Unity 6 — uselinearVelocity(andangularVelocityis unchanged).- Setting
transform.positionon a dynamic Rigidbody — teleports it, skips collision. UseMovePosition(kinematic/interpolated) or apply forces. - Applying forces in
Update— frame-rate-dependent and jittery. Physics goes inFixedUpdate. - 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) — set the Rigidbody's Collision Detection
to
Continuous(orContinuous Dynamic) for bullets/fast movers. - Non-uniform-scaled
MeshColliders or scaled colliders misbehave; prefer primitive colliders and keep scale uniform. - 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.
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.
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Unity 6 物理引擎的完整开发工作流,涵盖 Rigidbody、碰撞检测、射线检测等核心功能
- 包含多个可直接复用的 C# 代码示例(如力驱动移动、地面检测、触发器处理)
- 明确区分适用与不适用场景,帮助用户精准选择工具
Highlights
- 触发描述清晰明确,'Unity物理引擎专用技能'精准定位目标用户
- 'When to use' 章节详细列举典型使用场景与非使用场景,边界清晰
- 有效避免与其他 Unity 相关技能(如输入系统、导航网格)混淆
Areas to improve
-
缺少显式 Phase 划分与出口条件 Reported severity: Minor
文档虽有良好的步骤划分(Core workflow),但未使用显式的 Phase 标题和明确的出口条件描述
Recommendation: 建议在 Core workflow 中增加 Phase 1/2/3 等显式阶段划分,并为每个阶段补充出口条件说明
Highlights
- 文档结构完整,包含工作流、模式、陷阱、参考等必要章节
- frontmatter 信息完整,包含名称、版本、描述、分类等关键字段
- 代码示例丰富且格式规范,便于开发者直接参考使用
Highlights
- 所有代码示例均基于 Unity 6 最新 API(如 linearVelocity),确保兼容性
- 详细列出 7 个常见陷阱及解决方案,显著降低执行失败风险
- 工具来源明确(Unity 官方 PhysX 引擎),参数使用规范合理
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.