gamedev-unity/skills/unity-skills/skills/physics/SKILL.md
Run Unity physics queries and configure physics at editor time — raycasts, overlap checks, gravity, and physics settings. Use when casting rays, testing overlaps, querying colliders, or adjusting gravity/physics settings, even if the user just says "射线检测" or "物理设置". 执行 Unity 物理查询并在编辑器期配置物理(raycast、overlap 检测、重力、物理设置);当用户要发射射线、检测重叠、查询碰撞体、或调整重力/物理设置时使用。
npx skillsauth add bernatmv/ai-rules unity-physicsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Editor-time physics queries (raycast / overlap), gravity, PhysicMaterial assets, and layer collision matrix.
physics_raycast / physics_check_overlap / physics_get_gravity / physics_get_layer_collision 等,源码标 SkillMode.SemiAuto)直接执行;变更类(physics_set_gravity / physics_create_material / physics_set_material / physics_set_layer_collision,标 SkillMode.FullAuto)需用户 grant,grant 后服务端一步执行返结果。DO NOT (common hallucinations):
physics_add_rigidbody / physics_add_collider do not exist → use component_add with componentType "Rigidbody"/"BoxCollider"/etc.physics_simulate does not exist → physics simulation runs during Play mode; this module does not step the simulationRouting:
component modulephysics_create_material (this module)physics_set_layer_collision (this module)physics_raycastCast a ray and get hit info. Parameters:
originX, originY, originZ (float): Origin point.dirX, dirY, dirZ (float): Direction vector.maxDistance (float, optional): Max distance (default 1000).layerMask (int, optional): Layer mask (default -1).Returns: { hit: true, collider: "Cube", distance: 5.2, ... }
physics_check_overlapCheck for colliders in a sphere. Parameters:
x, y, z (float): Center point.radius (float): Sphere radius.layerMask (int, optional): Layer mask.physics_get_gravityGet global gravity setting. Parameters: None.
physics_set_gravitySet global gravity setting. Parameters:
x, y, z (float): Gravity vector (e.g. 0, -9.81, 0).physics_raycast_allCast a ray and return ALL hits (penetrating).
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | originX | float | Yes | - | Ray origin X | | originY | float | Yes | - | Ray origin Y | | originZ | float | Yes | - | Ray origin Z | | dirX | float | Yes | - | Direction X | | dirY | float | Yes | - | Direction Y | | dirZ | float | Yes | - | Direction Z | | maxDistance | float | No | 1000 | Max ray distance | | layerMask | int | No | -1 | Layer mask filter |
Returns: { count, hits: [{ objectName, instanceId, path, point, normal, distance }] }
physics_spherecastCast a sphere along a direction and get hit info.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | originX | float | Yes | - | Origin X | | originY | float | Yes | - | Origin Y | | originZ | float | Yes | - | Origin Z | | dirX | float | Yes | - | Direction X | | dirY | float | Yes | - | Direction Y | | dirZ | float | Yes | - | Direction Z | | radius | float | Yes | - | Sphere radius | | maxDistance | float | No | 1000 | Max cast distance | | layerMask | int | No | -1 | Layer mask filter |
Returns: { hit, objectName, instanceId, point, distance }
physics_boxcastCast a box along a direction and get hit info.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | originX | float | Yes | - | Origin X | | originY | float | Yes | - | Origin Y | | originZ | float | Yes | - | Origin Z | | dirX | float | Yes | - | Direction X | | dirY | float | Yes | - | Direction Y | | dirZ | float | Yes | - | Direction Z | | halfExtentX | float | No | 0.5 | Box half extent X | | halfExtentY | float | No | 0.5 | Box half extent Y | | halfExtentZ | float | No | 0.5 | Box half extent Z | | maxDistance | float | No | 1000 | Max cast distance | | layerMask | int | No | -1 | Layer mask filter |
Returns: { hit, objectName, instanceId, point, distance }
physics_overlap_boxCheck for colliders overlapping a box volume.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | x | float | Yes | - | Box center X | | y | float | Yes | - | Box center Y | | z | float | Yes | - | Box center Z | | halfExtentX | float | No | 0.5 | Box half extent X | | halfExtentY | float | No | 0.5 | Box half extent Y | | halfExtentZ | float | No | 0.5 | Box half extent Z | | layerMask | int | No | -1 | Layer mask filter |
Returns: { count, colliders: [{ objectName, path, isTrigger }] }
physics_create_materialCreate a PhysicMaterial asset.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | "New PhysicMaterial" | Material name | | savePath | string | No | "Assets" | Save directory path | | dynamicFriction | float | No | 0.6 | Dynamic friction value | | staticFriction | float | No | 0.6 | Static friction value | | bounciness | float | No | 0 | Bounciness value |
Returns: { success, path }
physics_set_materialSet PhysicMaterial on a collider (supports name/instanceId/path).
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | materialPath | string | Yes | - | Asset path of the PhysicMaterial | | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path |
Returns: { success, gameObject, material }
physics_get_layer_collisionGet whether two layers collide.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | layer1 | int | Yes | - | First layer index | | layer2 | int | Yes | - | Second layer index |
Returns: { layer1, layer2, collisionEnabled }
physics_set_layer_collisionSet whether two layers collide.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | layer1 | int | Yes | - | First layer index | | layer2 | int | Yes | - | Second layer index | | enableCollision | bool | No | true | Whether to enable collision |
Returns: { success, layer1, layer2, collisionEnabled }
import unity_skills
# Raycast from position downward, check for hits
result = unity_skills.call_skill("physics_raycast",
originX=0, originY=5, originZ=0,
dirX=0, dirY=-1, dirZ=0,
maxDistance=10
)
if result.get("hit"):
print(f"Hit: {result['hitObjectName']} at distance {result['distance']}")
Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.
development
Keyword research and validation with real search-demand data — never ship keywords from intuition alone. Probes Google Autocomplete per language (free, no account) to prove demand and discover the exact phrasing people type, checks SERPs for winnability, and uses Keyword Planner/Ahrefs/Semrush exports when the user has access. Activates when: choosing or reviewing SEO keywords, meta keywords, page titles, article topics or slugs, landing page copy targeting search, App Store/ASO keyword fields, multilingual keyword sets, 'what should we rank for', 'keyword analysis', or auditing why a page doesn't rank. Also invoke it as a validation pass whenever another skill or task produces a keyword list.
development
Automate YooAsset hot-update and asset bundles — build bundles, run Editor simulate builds, manage Collector groups, analyze BuildReport, and validate runtime. Use when building or simulating YooAsset bundles, configuring collectors, or validating hot-update assets, even if the user just says "热更" or "打AB包". 自动化 YooAsset 热更新与资源包(构建 bundle、编辑器模拟构建、管理 Collector 分组、分析 BuildReport、运行时校验);当用户要构建或模拟 YooAsset 资源包、配置 collector、或校验热更资源时使用。
development
Source-anchored design rules for YooAsset v2.3.18 — initialization, default-package shortcuts, play modes, asset handles, loading, updates, filesystem, build, and pitfalls. Use when writing or reviewing YooAsset code, initializing packages, loading assets via handles, setting up hot-update/download, or choosing a play mode, even if the user just says "热更" or "资源包". 为 YooAsset v2.3.18 提供源码锚定的设计规则(初始化、默认包快捷方式、运行模式、资源句柄、加载、更新、文件系统、构建、陷阱);当用户要编写或审查 YooAsset 代码、初始化 package、用句柄加载资源、配置热更/下载、或选择运行模式时使用。
data-ai
Last-resort guidance for safely hand-editing Unity serialized YAML (.unity/.prefab/.asset/.meta/ProjectSettings) — reference/fileID repair, GUID safety, and merge-conflict fixes. Use when REST cannot reach the change and YAML must be hand-edited — fixing m_Script GUIDs, broken fileID references, .meta files, or merge conflicts, even if the user just says "场景文件打不开" or "引用丢了". 安全手编 Unity 序列化 YAML(.unity/.prefab/.asset/.meta/ProjectSettings)的最后手段(引用/fileID 修复、GUID 安全、合并冲突修复);当 REST 无法触达、必须手编 YAML 时使用——修复 m_Script GUID、断裂 fileID 引用、.meta 文件或合并冲突。