godot-physics
БесплатноБез исполняемых скриптовНе проверенGodot 4.7 physics API in 2D and 3D: body and Area types, collision_layer and mask bits, Area signals for hurtboxes, RayCast and space queries, and Jolt (3D…
от gamedev-skills★ 12 656 звёзд на GitHubОб этом скилле
Godot Physics (4.x, 2D + 3D)
Pick the body type, wire collision layers and masks, detect overlaps, cast rays, and know
where Jolt differs. Swap the 2D/3D suffix as needed. Targets Godot 4.7 (see Version
notes). 2D always uses Godot's own 2D engine.
When to use
- Choosing a body type, setting layers/masks so the right things collide, overlap
detection (triggers, hurtboxes) with
Area, forces/impulses on aRigidBody, or rays for line-of-sight and ground checks.
When not to use: move_and_slide controllers → godot-2d-movement; tile collision
setup → godot-tilemap; engine-neutral feel (timestep, mass, jitter, CCD strategy) →
physics-tuning.
Core workflow
For 3D, read which engine runs before debugging behavior. In
project.godot,[physics]3d/physics_engine="Jolt Physics"means Jolt; no line (DEFAULT) means GodotPhysics3D. New 4.6+ projects write the Jolt line. The API is the same, but joints, ray face indices, kinematic contacts and margins differ (see Gotchas).Choose the body type:
StaticBodynever moves;AnimatableBodyis moved by code or animation and pushes others (platforms, doors);RigidBodyis simulated (move it with forces, impulses orlinear_velocity, neverposition);CharacterBodyis script-driven;Areaonly detects and can override gravity/damping. Every body needs a non-emptyCollisionShape/CollisionPolygonchild.Configure layers and masks. Layers are what a body is; masks are what it scans. A detects B only if B's layer bit is in A's mask. Name the bits in
project.godotso the.tscnvalues are readable:[layer_names] 2d_physics/layer_1="player" 2d_physics/layer_2="walls" 2d_physics/layer_3="enemies"In a
.tscn,collision_layer = 1andcollision_mask = 6(bits 2 and 3) are plain integers; bit n is1 << (n - 1). In code,set_collision_mask_value(3, true)uses the same 1-based numbers as the editor checkboxes.Detect overlaps with
Areasignals (body_entered,area_entered);monitoringon the detecting Area,monitorableon the detected one.Cast rays with a
RayCast2D/3Dnode (polled each physics frame) or a one-shotdirect_space_statequery (Pattern 2).Check before you finish. Physics runs normally under
--headless, so prove the behavior with a test runner instead of describing it (Pattern 3). Rungodot --headless --path . --script res://tests/test_physics.gdand read the exit code and anySCRIPT ERROR/ERROR:lines. With no Godot binary (godot,godot4or$GODOT_BIN), ask the user to run it and paste the output. For a visual check, ask the user to rungodot --path . --debug-collisionsand report what overlaps. If you edited.tscnfiles by hand, also run thegodot-nodes-scenesskill'sscripts/check_godot_project.py <project-dir>.
Patterns
1. RigidBody: impulse, force, and a safe teleport
extends RigidBody3D
var _teleport_to: Variant = null
func push(direction: Vector3) -> void:
apply_central_impulse(direction * 8.0) # one-off velocity change
func teleport(to: Transform3D) -> void:
_teleport_to = to # applied inside the solver step
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
if _teleport_to != null:
state.transform = _teleport_to
state.linear_velocity = Vector3.ZERO
state.angular_velocity = Vector3.ZERO
_teleport_to = null
2. One-shot ray that skips the caster
func ground_under(from: Vector2) -> Dictionary:
var space := get_world_2d().direct_space_state
var query := PhysicsRayQueryParameters2D.create(from, from + Vector2(0, 64))
query.collision_mask = 0b10 # layer 2 only ("walls")
query.exclude = [get_rid()] # Array[RID], not nodes
return space.intersect_ray(query) # {} on miss, else collider/position/normal
Call it from _physics_process; space-state data is only valid during the physics step.
3. Headless test that an Area sees a body
# res://tests/test_physics.gd
extends SceneTree
func _initialize() -> void:
var level: Node = load("res://levels/test_arena.tscn").instantiate()
root.add_child(level)
for _i in 3:
await physics_frame # overlap lists update once per step
var hurtbox: Area2D = level.get_node("Hurtbox")
var player: Node2D = level.get_node("Player")
var ok := hurtbox.overlaps_body(player)
print("hurtbox sees player: ", ok)
quit(0 if ok else 1)
Place the two nodes so they overlap in the test scene. The same shape works for "the crate
lands on the floor" (compare global_position.y after N frames) or "the ray hits the
wall". Add counters as in godot-gdscript-headless-testing once there is more than one
assertion.
Gotchas
- **Layer vs mas
Установить godot-physics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл godot-physics?
Godot 4.7 physics API in 2D and 3D: body and Area types, collision_layer and mask bits, Area signals for hurtboxes, RayCast and space queries, and Jolt (3D default since 4.6). Use when objects pass through each other, body_entered never fires or a raycast hits itself. Not for engine-neutral jitter and tunnelling (`physics-tuning`) or CharacterBody movement (`godot-2d-movement`).
Как установить скилл godot-physics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл godot-physics запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic