All skills

Use Godot 4.7 physics bodies and detection in 2D and 3D: RigidBody, StaticBody, Area, and CharacterBody; collision layers vs masks; contact/overlap signals; and raycasts (RayCast nodes and direct space-state queries). Use when configuring collision layers/masks, detecting overlaps with Area2D/Area3D, applying forces to a RigidBody, or casting rays in a Godot project (.tscn with physics bodies), including 3D projects running Jolt Physics, the default 3D engine for projects created in 4.6+.

Use this Skill: https://skilld.dev/gh/gamedev-skills/awesome-gamedev-agent-skills/godot-physics

This session only. Nothing lands on disk.

referencesbodies-and-queries.md

≈991 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Physics bodies & space queries reference (Godot 4.7)

Depth companion to godot-physics. Use the 2D/3D suffix to match your world.

Body type cheat sheet

Node Moves? Simulated? Move it by Use for
StaticBody2D/3D No No (don't) Level geometry, walls, floors
AnimatableBody2D/3D Yes (scripted/anim) No animation / position Moving platforms, doors
RigidBody2D/3D Yes Yes forces / impulses / linear_velocity Props, debris, balls
CharacterBody2D/3D Yes (scripted) No velocity + move_and_slide() Players, enemies
Area2D/3D Yes No (detection only) position Triggers, hurt/hitboxes, water

Collision layer/mask helpers

set_collision_layer_value(bit, enabled)   # 1-based bit (matches editor checkboxes)
set_collision_mask_value(bit, enabled)
get_collision_layer_value(bit) -> bool
collision_layer = 0b0101                   # raw bitmask (advanced)

Name layers in Project Settings > Layer Names > 2D/3D Physics so the editor checkboxes read like Player, Walls, Enemies.

RigidBody control

apply_central_impulse(v)     # instant velocity change at center of mass
apply_impulse(v, pos)        # impulse at an offset -> adds spin
apply_central_force(v)       # continuous force (apply each _physics_process)
apply_torque_impulse(t)      # instant angular change
linear_velocity = v          # direct set (use sparingly)
freeze = true                # stop simulation; freeze_mode = FREEZE_MODE_KINEMATIC|STATIC
gravity_scale = 0.0          # disable gravity for this body

Full control via _integrate_forces:

func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
    state.linear_velocity = state.linear_velocity.limit_length(max_speed)
    # To teleport safely: state.transform = new_transform; state.linear_velocity = Vector3.ZERO

Enable contact_monitor and set max_contacts_reported > 0 to receive body_entered/body_exited on a RigidBody.

Space-state queries (code-driven, no node)

var space := get_world_3d().direct_space_state

# Ray
var rq := PhysicsRayQueryParameters3D.create(from, to)
rq.collision_mask = 0b0010
rq.exclude = [self.get_rid()]
var hit := space.intersect_ray(rq)   # {position, normal, collider, collider_id, rid, shape}

# Shape overlap (e.g. "what's inside this sphere?")
var shape := SphereShape3D.new(); shape.radius = 2.0
var sq := PhysicsShapeQueryParameters3D.new()
sq.shape = shape
sq.transform = Transform3D(Basis(), global_position)
var hits := space.intersect_shape(sq, 32)  # array of {collider, rid, shape}

intersect_point (2D) and cast_motion/collide_shape cover point picks and swept tests. Space-state queries must run during physics (_physics_process) for valid data.

RayCast node tips

  • Set target_position (relative to the node) and enabled = true.
  • is_colliding(), get_collider(), get_collision_point(), get_collision_normal().
  • collide_with_areas / collide_with_bodies toggle what it detects.
  • After moving the ray within a frame, call force_raycast_update() before reading.
  • add_exception(node) / add_exception_rid(rid) to skip specific colliders.

Joints

PinJoint, HingeJoint, SliderJoint, Generic6DOFJoint (3D) and PinJoint2D, GrooveJoint2D, DampedSpringJoint2D (2D) connect two bodies. Assign node_a/node_b to the bodies' paths. Use for ragdolls, chains, vehicles, swinging platforms.

One-way collision

On a CollisionShape2D/CollisionPolygon2D, enable one_way_collision so bodies pass from one side only (platforms). The pass-through direction is the shape's local up.

Areas with physics influence

An Area can override gravity/damping in its region (gravity_space_override, gravity, linear_damp) — useful for water, wind, or low-gravity zones affecting any RigidBody inside.

Source: SKILL.md on GitHub

No alerts5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    This skill provides documentation and code examples for working with physics in the Godot 4.7 engine. No security risks or malicious patterns were detected.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at e4e9569. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated last week

README badge

README badge for gamedev-skills/awesome-gamedev-agent-skills/godot-physics