Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(platformer): clamp fall speed, note step-integration height error, fix corner correction, add engine one-way and moving-platform behaviour

Kiro Crewe8a9aa9cd825
diff --git a/skills/genres/platformer/SKILL.md b/skills/genres/platformer/SKILL.md
index a85a1bd..1986994 100644
--- a/skills/genres/platformer/SKILL.md
+++ b/skills/genres/platformer/SKILL.md
@@ -94,21 +94,31 @@ if buffer_timer > 0 and coyote_timer > 0:
if jump_released_this_frame and velocity.y < 0:
velocity.y *= 0.45
-# Asymmetric gravity: snappier fall than rise.
+# Asymmetric gravity: snappier fall than rise; clamp to a terminal speed.
g = fall_gravity if velocity.y > 0 else gravity
-velocity.y += g * dt
+velocity.y = min(velocity.y + g * dt, MAX_FALL_SPEED)
```
### 3. One-way platforms
-Solid from above, pass-through from below. Most engines expose a "one-way collision" flag on
-the tile/collider; enable it and let the player **drop through** by disabling that collision
-for a few frames when the player holds Down + Jump. Do not re-implement collision math.
+Solid from above, pass-through from below. Use the engine's flag rather than collision math:
+Godot `CollisionShape2D.one_way_collision` (or the one-way option on a TileSet collision
+polygon), Unity a `PlatformEffector2D` with **Use One Way** on a collider set to be used by the
+effector, Phaser Arcade `platform.body.checkCollision.down = false` (plus `left`/`right` for thin
+ledges). Let the player **drop through** by ignoring that platform for ~0.1–0.2 s when they hold
+Down + Jump (refs §5).
## Pitfalls / failure modes
- **Per-frame movement not scaled by `dt`** → speed changes with frame rate. Every velocity
integration and timer must use `dt`. (See `physics-tuning`.)
+- **Jump height differs between machines** → the jump runs on a variable render `dt`. Simple
+ per-step integration lands a few percent short of the designed height, by a different amount
+ at each frame rate. Run the controller on the fixed physics tick (Godot `_physics_process`,
+ Unity `FixedUpdate`) or use the half-step update in refs §1.
+- **Player is flung off or doubles speed leaving a moving platform** → platform velocity added
+ twice. Godot's `CharacterBody2D` already carries the body and adds the platform's velocity on
+ leave (`platform_on_leave`); don't add it again in script (refs §6).
- **Floaty jumps** → symmetric gravity. Make fall gravity heavier than rise gravity.
- **"The jump didn't register"** → no input buffering. Buffer presses for ~0.1 s before landing.
- **"I fell off and couldn't jump"** → no coyote time. Allow a jump for ~0.1 s after leaving ground.
diff --git a/skills/genres/platformer/references/feel-tuning.md b/skills/genres/platformer/references/feel-tuning.md
index 9843b1e..e1143cd 100644
--- a/skills/genres/platformer/references/feel-tuning.md
+++ b/skills/genres/platformer/references/feel-tuning.md
@@ -26,6 +26,18 @@ fall_gravity = g * fall_multiplier # 1.5–2.0 feels good
If you instead know the jump velocity and want the height: `h = v0² / (2g)`.
+These formulas describe continuous motion. A game integrates in steps, and the usual
+"add gravity to velocity, then add velocity to position" update peaks short by about
+`v0 · dt / 2`: with a 56 px jump and a 0.35 s apex that is ~2.7 px at 60 Hz and ~5 px at 30 Hz.
+Fixed-tick physics keeps the error the same on every machine (tune by eye and accept it). To hit
+the designed height exactly, apply half the gravity before the move and half after:
+
+```python
+velocity.y += 0.5 * g * dt
+position.y += velocity.y * dt # or move_and_slide() / CharacterController.Move here
+velocity.y += 0.5 * g * dt
+```
+
## 2. Full feel knob reference
| Knob | What it changes | Typical range | Notes |
@@ -60,23 +72,36 @@ When a rising jump clips a corner by a pixel or two, players read it as the game
"sticky". Nudge them past it instead of stopping the jump dead:
```python
-# On hitting a ceiling while rising, if only the outer 1–4 px are blocked,
-# shift the body sideways into the free space and keep the upward velocity.
+# On hitting a ceiling while rising, if only the outer 1–4 px are blocked, shift the body
+# sideways into the free space and keep the upward velocity. Test both directions, at the
+# position the body is trying to move to this step.
if blocked_overhead and velocity.y < 0:
- for offset in (1, 2, 3, 4): # check small horizontal nudges
- if free_at(position + sideways * offset):
- position += sideways * offset
- break # keep rising; don't zero velocity.y
+ target = position + Vector2(0, velocity.y * dt)
+ for offset in (1, 2, 3, 4): # smallest nudge first
+ for side in (-1, +1):
+ if free_at(target + Vector2(side * offset, 0)):
+ position.x += side * offset
+ break # keep rising; don't zero velocity.y
+ else:
+ continue
+ break
```
+Only nudge when the blocked part is a corner, never when the player is under a solid ceiling
+more than a few pixels wide; the 4 px cap is what enforces that.
+
The same idea on landing edges (a few px of "ledge grab"/snap) makes platforms feel generous.
## 5. One-way platforms and drop-through
- Mark the platform's collision as one-directional (solid only when the player is above and
- moving down). Engines expose this directly — do not hand-roll it.
+ moving down). Engines expose this directly — do not hand-roll it (Godot
+ `CollisionShape2D.one_way_collision`, Unity `PlatformEffector2D` **Use One Way**, Phaser Arcade
+ `body.checkCollision.down = false` on the platform).
- **Drop-through:** when the player holds Down + Jump on a one-way platform, disable that
collision for ~0.1–0.2 s (or until the player's top passes below the platform), then re-enable.
+ In Godot, clear the platform's layer from the player's `collision_mask` for that window rather
+ than disabling the shape, so other bodies still land on it.
## 6. Moving platforms
@@ -84,6 +109,14 @@ The same idea on landing edges (a few px of "ledge grab"/snap) makes platforms f
on it, so they ride it instead of sliding off.
- Apply the platform's velocity to the player on jump-off so leaps from a moving platform feel
physical. Cap the inherited horizontal velocity so it can't fling the player uncontrollably.
+- **Check what the engine already does before adding either.** Godot 4.7 `CharacterBody2D`
+ follows floor bodies on `platform_floor_layers` during `move_and_slide()` and, by default,
+ adds the platform's velocity when you leave it (`platform_on_leave =
+ PLATFORM_ON_LEAVE_ADD_VELOCITY`; `ADD_UPWARD_VELOCITY` drops the downward part, `DO_NOTHING`
+ turns it off). Move the platform as an `AnimatableBody2D` so it reports a velocity. Phaser
+ Arcade carries a rider horizontally when the platform is an immovable *dynamic* body that is
+ moving (`body.friction`, default `(1, 0)`); a static body does not. Unity's
+ `CharacterController` does not carry riders; add the delta yourself.
## 7. Camera follow