- name
SKILL.md
技能文件保留在发布者的仓库中。
在终端中粘贴复制的命令。它会把这个 SKILL.md 安装到对应的智能体中。
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill camera-systems -a cursor -y在终端中粘贴复制的命令。它会把这个 SKILL.md 安装到对应的智能体中。
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill camera-systems -a claude-code -y在终端中粘贴复制的命令。它会把这个 SKILL.md 安装到对应的智能体中。
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill camera-systems -a codex -y在终端中粘贴复制的命令。它会把这个 SKILL.md 安装到对应的智能体中。
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill camera-systems -a grok -y在 Grok Bot 聊天中发送复制的消息。Bot 会从 GitHub 获取这个 SKILL.md,并添加到你所有 Bot 共享的技能中。
Install this skill: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/tree/HEAD/skills/disciplines/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.
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).
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.1 - exp(-rate * dt) or a critically damped spring (SmoothDamp), never a
fixed lerp(a, b, 0.1) per frame.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.# 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
# 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.
# 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
# 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.y * sensitivity,
deg_to_rad(-80.0), deg_to_rad(45.0)) # clamp pitch!
func _process(_dt):
pivot.rotation = Vector3(_pitch, _yaw, 0)
# $SpringArm3D handles wall collision: set spring_length + collision_mask; the child
# Camera3D slides in automatically. RIGHT: spring arm. WRONG: camera clips through walls.
# Unity 6.3 LTS: a Cinemachine 3 CinemachineCamera (namespace Unity.Cinemachine) with an Orbital
# Follow + Cinemachine Deoccluder; the CinemachineBrain on the Camera blends automatically.
game-feel)# Expose an additive offset the game-feel trauma model writes to; follow + shake compose.
var shake_offset := Vector2.ZERO # set each frame by game-feel (trauma^2 * noise)
func _apply(final_focus: Vector2) -> void:
global_position = final_focus + shake_offset # shake rides ON TOP of smooth follow
# Unity Cinemachine 3: CinemachineBasicMultiChannelPerlin (AmplitudeGain/FrequencyGain) for
# continuous noise driven by trauma; for one-off impacts, a CinemachineImpulseSource on the
# hitter plus a CinemachineImpulseListener on the camera.
lerp(pos, target, const) per frame is frame-rate dependent: floatier at 30 FPS,
snappier at 144. Use 1 - exp(-rate * dt) or SmoothDamp.physics/common/physics_interpolation) and follow the body's interpolated transform in
_process (get_global_transform_interpolated() in 3D), or follow in the physics step with
Camera2D.process_callback = CAMERA2D_PROCESS_PHYSICS. Mixing the two is what jitters.LateUpdate (Unity) or after movement and physics resolve.top_level = true) and follow in code or with a rig.[min + half_view, max - half_view], and centre on any axis where the level is smaller than
the view.InputEventMouseMotion.relative
is scaled by the stretch settings; read screen_relative for captured-mouse aiming.Camera2D.reset_smoothing()), or fast-ease deliberately.references/follow-and-framing.md: read for the smoothing derivation, a full deadzone plus
look-ahead plus bounds 2D rig, orbit and first-person details, group framing and
split-screen, cutscene blends, and the Godot/Cinemachine 3 component mapping table.game-feel: shake trauma and triggers; writes this skill's offset.godot-2d-movement, godot-3d-essentials: the player and world the camera frames.physics-tuning: timestep and interpolation for the bodies being followed.input-systems: look sensitivity, invert and stick response curves.Last verified: 2026-11-11.
Camera2D.position_smoothing_*, limit_*, drag_*, process_callback,
reset_smoothing(); InputEventMouseMotion.screen_relative; physics interpolation and manual
camera interpolation per
https://docs.godotengine.org/en/4.7/tutorials/physics/interpolation/advanced_physics_interpolation.html.Unity.Cinemachine). The 2.x names CinemachineVirtualCamera, CinemachineCollider and
CinemachineFramingTransposer are deprecated in 3.x
(https://packages.unity.com/com.unity.cinemachine).>
---name: camera-systemsdescription: >---# skills/disciplines/camera-systems/SKILL.md常见问题
从发布者处下载 skills/disciplines/camera-systems/SKILL.md,或复制路径后打开仓库。PlugMCP 只收录该技能,不托管文件。
发布者将它存放在 https://github.com/gamedev-skills/awesome-gamedev-agent-skills。
Claude、Cursor、Codex 和 Grok Build 可以读取你从发布者仓库添加的 SKILL.md。在聊天中发送技能的 GitHub 文件夹链接,Grok Bot 就会安装它。