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(fps-shooter): sample spread in a cone, keep recoil as a look offset, document ray query pitfalls

Kiro Crew9fc4eae46245
diff --git a/skills/genres/fps-shooter/SKILL.md b/skills/genres/fps-shooter/SKILL.md
index 266d01f..6c048f6 100644
--- a/skills/genres/fps-shooter/SKILL.md
+++ b/skills/genres/fps-shooter/SKILL.md
@@ -59,8 +59,8 @@ responsive look, clear hit feedback, and a death that reads instantly.
```python
# Pseudocode. Cast from the camera; first hit takes damage scaled by range + headshot.
-direction = apply_spread(camera.forward, current_spread)
-hit = raycast(camera.world_position, direction, max_dist=RANGE, mask=SHOOTABLE)
+direction = apply_spread(camera.forward, current_spread) # cone sample, see refs §4
+hit = raycast(camera.world_position, direction, max_dist=RANGE, mask=SHOOTABLE, exclude=[shooter])
if hit:
dmg = base_damage * falloff(hit.distance)
if hit.is_head: dmg *= HEADSHOT_MULT
@@ -89,7 +89,13 @@ ttk_seconds = (shots_to_kill - 1) / fire_rate_per_second # first shot at t=0
## Pitfalls / failure modes
- **Look tied to frame rate or unscaled by `dt`** → sensitivity changes with FPS. Look should
- be driven by raw mouse delta; movement integration uses `dt` (see `physics-tuning`).
+ be driven by raw mouse delta (never multiplied by `dt`); movement integration uses `dt`
+ (see `physics-tuning`). Clamp pitch to about ±89° so the view cannot flip over.
+- **Shots that "do nothing"** → the ray hits the shooter's own collider, misses hitboxes built
+ from trigger/area volumes, or stops on an invisible trigger zone. Exclude the shooter and set
+ the trigger rule explicitly per engine (refs §2 table).
+- **Recoil recovery fights the player's aim** → recoil was written into the look angle. Keep it
+ as a separate offset that decays to zero (refs §4).
- **Pure random recoil/spread** → feels uncontrollable and unfair. Use a learnable recoil
pattern; keep the first shot accurate.
- **Hitscan with no falloff** → pistols snipe across the map. Add range-based damage falloff.
diff --git a/skills/genres/fps-shooter/references/shooting-and-feel.md b/skills/genres/fps-shooter/references/shooting-and-feel.md
index 6e8dae9..582527f 100644
--- a/skills/genres/fps-shooter/references/shooting-and-feel.md
+++ b/skills/genres/fps-shooter/references/shooting-and-feel.md
@@ -25,7 +25,7 @@ at long range without falloff.
origin = camera.world_position
direction = camera.forward
direction = apply_spread(direction, current_spread) # see §4
-hit = raycast(origin, direction, max_dist=RANGE, mask=SHOOTABLE)
+hit = raycast(origin, direction, max_dist=RANGE, mask=SHOOTABLE, exclude=[shooter])
if hit:
dmg = base_damage * falloff(hit.distance) # see §3
if hit.is_head: dmg *= HEADSHOT_MULT # e.g. 2.0
@@ -33,6 +33,17 @@ if hit:
spawn_impact_fx(hit.point, hit.normal) # decal + particles = feedback
```
+Engine query details that silently drop hits (check these before tuning anything):
+
+| | Godot 4.7 (`PhysicsRayQueryParameters3D`) | Unity 6.3 (`Physics.Raycast`) |
+|---|---|---|
+| Skip the shooter | `exclude = [shooter.get_rid()]` or a `collision_mask` without the player layer | a `layerMask` without the player layer |
+| Trigger / area volumes | `Area3D` is ignored unless `collide_with_areas = true` (hitboxes built from areas need it) | triggers **are** hit while the project's *Queries Hit Triggers* setting is on (the default), so pickup and zone triggers stop bullets; pass `QueryTriggerInteraction.Ignore` per shot, or `Collide` if your hitboxes are triggers |
+| Ray starting inside a collider | not reported unless `hit_from_inside = true` | that collider is not hit |
+
+Third-person or muzzle-blocked shots: cast from the camera to find the aim point, then from the
+muzzle to that point, so cover directly in front of the gun still blocks the bullet.
+
## 3. Damage falloff (range limiting for hitscan)
```python
@@ -52,19 +63,24 @@ def falloff(d, near=20.0, far=60.0, min_mult=0.4):
pure random recoil feels bad. Recover toward the original aim over time.
```python
-# Spread: random offset within a cone whose half-angle = current_spread.
+# Spread: a random direction inside a cone whose half-angle = spread_rad.
+# Picking yaw and pitch independently fills a square, not a cone (corners reach 1.41x spread).
def apply_spread(dir, spread_rad):
- yaw = rng.range(-spread_rad, spread_rad)
- pitch = rng.range(-spread_rad, spread_rad)
- return rotate(dir, yaw, pitch)
+ r = spread_rad * sqrt(rng.float01()) # sqrt -> hits uniform over the disc
+ theta = rng.float01() * TAU # drop the sqrt for a centre-weighted pattern
+ return rotate(dir, yaw=r * cos(theta), pitch=r * sin(theta))
-# On each shot: grow spread and kick the camera; recover every frame.
+# Keep recoil as an offset on top of the player's look, so recovery never fights the mouse.
def on_fire():
- camera.pitch -= recoil_pattern[shot_index % len(recoil_pattern)] # learnable kick
+ recoil_offset += recoil_pattern[min(shot_index, len(recoil_pattern) - 1)] # learnable kick
+ shot_index += 1
current_spread = min(current_spread + SPREAD_PER_SHOT, MAX_SPREAD)
def tick(dt):
current_spread = max(BASE_SPREAD, current_spread - SPREAD_RECOVER * dt)
- camera.pitch = move_toward(camera.pitch, aim_pitch, RECOIL_RECOVER * dt)
+ recoil_offset = move_toward(recoil_offset, 0.0, RECOIL_RECOVER * dt)
+ if time_since_last_shot > PATTERN_RESET: shot_index = 0 # pattern restarts per burst
+ # look_pitch comes only from mouse/stick input; positive = up here, check your engine's sign.
+ camera.pitch = clamp(look_pitch + recoil_offset, -MAX_PITCH, MAX_PITCH) # e.g. ±89°
```
## 5. Time-to-kill (TTK) — the master balance lever