Get updates ↗

Game feel

Camera deadzone in game development

let the player move first

Interactive example · scroll or point here to play
14

let the player move first

A camera deadzone is a box in the middle of the screen where the player can move while the camera stays still. When the player pushes past an edge, the camera moves just enough to keep them on that edge, so small steps and turnarounds leave the view steady. Here the camera holds still each time the player turns back and crosses the box.

prompt bit
Give the follow camera a deadzone: keep the camera still while the player is inside a centered box about a quarter of the screen wide, and when they cross an edge, move the camera by exactly how far they went past it.

When to use it

Use a deadzone when small player movements should not constantly move the view. Combine it with world bounds, and optionally a small look-ahead offset in the movement direction.

Implementation example

Engine-neutral pseudocode. Adapt the functions and coordinate conventions to your engine.

offset = player.position - camera.position
excess.x = offset.x - clamp(offset.x, -halfWidth, halfWidth)
excess.y = offset.y - clamp(offset.y, -halfHeight, halfHeight)
camera.position += excess

Common mistakes

Clamp the final camera target to level bounds. If smoothing is added, distinguish the target deadzone from the lagging camera position to avoid oscillation near the edges.

Maintained by Nicolas Zullo · Follow on X ↗