Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

camera-systems

FreeNo executable scriptsNot checked

Builds and tunes game cameras, engine-neutral with Godot and Cinemachine 3 mappings: 2D follow with deadzone and look-ahead, third-person orbit, first-person…

gamedev-skillsby gamedev-skills★ 12,656 GitHub stars

About this skill

Camera systems

A good camera follows smoothly at any frame rate, leads the action, never shows outside the level and never clips through walls. This skill owns those techniques and maps them onto each engine's camera node or rig; prefer the engine's built-in rig before hand-rolling one.

When to use

  • A 2D camera should follow smoothly, ignore small movements, lead motion and stay in bounds.
  • A 3D third-person orbit or first-person look controller, or framing several targets.
  • Fixing jitter, snapping, motion sickness or a camera that peeks past the level.

Not this skill: shake magnitude and triggers (game-feel; this skill only exposes the offset), physics jitter of the body itself (physics-tuning), Camera3D and environment setup (godot-3d-essentials), player movement (godot-2d-movement or the engine movement skill), look-sensitivity input curves (input-systems).

Core workflow

  1. Decide what the camera serves. Platformer (lead the jump, see hazards), top-down (centre with deadzone), third-person (orbit plus collision), first-person (look only).
  2. Use the built-in rig first: Godot Camera2D smoothing, limits and drag margins, or SpringArm3D; Unity Cinemachine 3 (CinemachineCamera plus Position Composer, Orbital Follow, Deoccluder, Confiner). Hand-roll only what the rig cannot do.
  3. Smooth with 1 - exp(-rate * dt) or a critically damped spring (SmoothDamp), never a fixed lerp(a, b, 0.1) per frame.
  4. Add a deadzone, then look-ahead eased toward its goal so direction flips don't whip.
  5. Clamp the view, not the centre, to the level rectangle, accounting for zoom.
  6. For 3D, separate look from collision: yaw and pitch on a pivot, a spring arm or ray pulls the camera in, pitch clamped.
  7. Update after the target moves (late update, or after physics) and follow the target's interpolated transform when physics interpolation is on.
  8. Verify with a runnable check, then by eye. Step the follow code headless with a target moving at 300 px/s for 2 s at dt = 1/30 and at dt = 1/144, and compare how far the camera trails the target. With rate = 8 exponential smoothing the lag is about 33 px and 37 px; a fixed lerp(..., 0.1) gives about 90 px and 19 px, a sign the follow is frame-rate dependent. Then ask the user to run into corners, walls and level edges at low and high frame rates and report any jitter, peeking or snapping.

Patterns

1. Godot 2D built-in follow: smoothing + bounds (don't hand-roll first)

# Godot 4.7 Camera2D. Engine-provided smoothing + hard limits + drag margins.
@onready var cam := $Camera2D
func _ready() -> void:
    cam.make_current()
    cam.position_smoothing_enabled = true
    cam.position_smoothing_speed = 6.0           # higher = snappier; lower = floatier
    cam.limit_left = 0; cam.limit_top = 0        # clamp to the level rect (pixels)
    cam.limit_right = level_width; cam.limit_bottom = level_height
    cam.drag_horizontal_enabled = true           # built-in deadzone via drag margins

2. Frame-rate-independent smooth follow (when you hand-roll it)

# RIGHT: exponential smoothing — same feel at any FPS. `rate` ~ 5..12.
func _follow(dt: float) -> void:
    var t := 1.0 - exp(-rate * dt)               # converges correctly regardless of dt
    global_position = global_position.lerp(target.global_position, t)
# WRONG: global_position = global_position.lerp(target.global_position, 0.1)
#        → faster smoothing at higher FPS; different feel on every machine.
# Unity 6.3 LTS: Vector3.SmoothDamp(transform.position, target.position, ref vel, smoothTime) in
# LateUpdate gives the same spring behavior with built-in frame-rate correction.

3. Deadzone + look-ahead (lead the player, ignore jitter)

# Camera only chases once the target leaves the deadzone box, then aims AHEAD of motion.
func _camera_target(dt: float) -> Vector2:
    var to := target.global_position - _focus
    var dz := deadzone_half_extents                  # e.g. Vector2(48, 32)
    # Only move the focus by the overflow beyond the deadzone (per axis).
    _focus.x += clampf(absf(to.x) - dz.x, 0, INF) * signf(to.x)
    _focus.y += clampf(absf(to.y) - dz.y, 0, INF) * signf(to.y)
    var lead := target.velocity.normalized() * look_ahead_dist    # aim ahead of travel
    return _focus + lead

4. 3D third-person orbit with collision push-in

# Godot 4.7. Yaw/pitch a pivot; a SpringArm3D auto-pulls the camera in when blocked.
func _unhandled_input(e):
    if e is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
        # screen_relative is unscaled; `relative` is scaled by the stretch settings, so
        # sensitivity would change with window size. The docs recommend screen_relative
        # for captured-mouse aiming.
        _yaw -= e.screen_relative.x * sensitivity
        _pitch = clampf(_pitch - e.screen_relative.
Full SKILL.md on GitHub

Install camera-systems in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

references/follow-and-framing.md

FAQ

What does the camera-systems skill do?

Builds and tunes game cameras, engine-neutral with Godot and Cinemachine 3 mappings: 2D follow with deadzone and look-ahead, third-person orbit, first-person look and split-screen. Use when the camera lags, jitters while following, shows past the level edge, clips through walls or changes with frame rate. Not for shake (`game-feel`) or physics timestep jitter (`physics-tuning`).

How do I install the camera-systems skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the camera-systems skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare camera-systems with