The bottom line
A good 2D camera does more than follow the hero: it looks ahead, ignores jumps, smooths its motion, frames key moments and adds juice. No single camera fits every game, so the design must match the game being made.
Key takeaways
- A camera pinned to the character is jittery, jumpy and short-sighted. 0:12
- A centred hero uses only half the screen for what is ahead, so the camera should focus on what is coming up.
- The camera should show the player what they need to see. 0:26
- Cave Story offsets the view in front of the player, and Nuclear Throne centres the camera between the character and the cursor.
- The camera should not follow every jump. 3:06
- Donkey Kong Country: Tropical Freeze moves the camera only after a landing on a higher platform.
- Shovel Knight levels are as tall as the screen, so the camera never moves up or down.
- Damping smooths the camera so it ignores small movements. 5:06
- Easing toward the character's position avoids erratic, jerky motion. Fez adds a dead zone where the character moves freely.
- Framing and juice make the camera part of the game's feel. 6:21
- Insanely Twisted Shadow Planet averages the position of the ship and key areas, and Celeste shakes the screen along the dash direction.
- Screen shake can bother some players, so offer an option to turn it off.
There's no such thing as a perfect camera that works for every game. It depends entirely on the thing you're making.
Game Maker's Toolkit
Chapter summaries
0:00 Intro
Pinning the camera to the hero is the obvious first move, and it makes a poor camera.
- A camera glued to the main character needs fixing. 0:06
- Every 2D game needs a camera to frame the action.
- Besides the jitter, a pinned camera is boringly static.
- Five quick tips follow, and each one fixes a flaw of the pinned camera.
- The tips are lookahead, jumping, damping, framing and juice.
0:26 Lookahead
The camera should spend its screen space on what is ahead of the player, not behind.
- Zooming out or shifting the camera ahead of the hero shows more of what's coming. 0:48
- Zooming out keeps the hero centred and still shows the way ahead.
- A fixed offset is enough for endless runners.
- A game with left and right movement must change the lookahead with the direction of travel.
- Cave Story keeps two camera positions and glides slowly from one to the other when you turn.
- The best lookahead follows what the player is doing. 1:37
- New Super Mario Bros. U leans right, but swings left of Mario once he backtracks for a while.
- Sonic Generations moves the camera further in front of Sonic as his speed builds, up to a maximum.
- Hyper Light Drifter offsets the camera a few feet in front of the hero's head, whichever way he faces.
- Luftrausers leads the camera only while the throttle is held, so stall-and-swing-around shots keep the prey in view.
- Enter the Gungeon, The Swapper and Hotline Miami frame the action in similar ways.
3:06 Jumping
A platformer camera should stay calm during jumps and move only when the level needs it.
- A camera that chases every jump makes players queasy and hurts their timing. 3:09
- Platformers are all about jumping, so a pinned camera moves constantly.
- Platforms can vanish beneath the screen when the camera lurches upwards.
- The movement also makes it hard to line up perfect jumps.
- There are two main fixes: ignore jumps in the code, or design the level around them.
- The code can ignore jumps and track vertically only in certain cases. 3:31
- In Tropical Freeze the camera breaks its own rule while you climb ropes or swim, and moves up and down freely.
- Rayman Legends tracks up only in predetermined areas where the level goes beyond the frame.
- Level design and offsets can remove the need for vertical movement. 4:15
- A level that fits in one screen needs no camera movement, which suits precision jumping.
- Placing the hero nearer the bottom of the screen gives more vertical room.
- The two axes needn't behave alike: left and right can work differently from up and down.
- Less need to move up and down means a steadier view.
5:06 Damping
| Pinned | Damping | Dead zone | |
|---|---|---|---|
| Follows hero | Exactly, every frame | Eases toward hero | Only past the window |
| Small movements | Shows every twitch | Smoothed out | Ignored |
| Main risk | Jerky, erratic | Hero gets ahead of view | Hero far off-centre |
| Good fit | Choppy retro 8-bit feel | Most games | Zoomed-out views (Fez) |
Letting the camera lag slightly behind the hero makes it smoother, but too much lag has a cost.
- A camera that tracks perfectly feels erratic. 5:09
- It reacts to every small movement, however tiny.
- The jerkiness is worst when making precision movements to line up a jump.
- Too much smoothing leaves the hero ahead of the camera. 5:35
- A slow camera leaves even less screen for looking ahead.
- A dead zone is the other cure, and the character can roam inside it without moving the camera.
- In Fez the dead zone leaves the character well off-centre when walking, but the camera is so zoomed out that it doesn't matter.
- A very responsive camera suits retro titles that want a choppy 8-bit feel.
- Otherwise even a tiny bit of damping makes a game feel smoother and more polished.
6:21 Framing
The camera should usually stay on the hero, but it can move, zoom or stop to frame other things.
- The camera can pull the player's eye to important objects or scenes. 6:37
- Disney Illusion Island zooms out and settles on a fixed view for a tricky platforming or puzzle area, then returns to tracking.
- In Insanely Twisted Shadow Planet, key areas such as checkpoints and puzzle zones have a sphere of influence. When the ship enters it, the camera finds the average position of the ship and the area.
- Pyre zooms and moves so the active character and the ball both stay prominent, since they matter equally.
- Moving or zooming the camera for effect gives a cinematic feel. 7:34
- Inside normally tracks ahead of the player, but shifts for a better view of the attackers when a pack of rabid dogs chases you.
- GRIS sometimes frames the hero tightly and sometimes draws far out to show the grand scale of a building.
- Blocking the camera from some areas keeps the frame on relevant things. 8:01
- Spelunky levels sit inside an impenetrable rocky border, and the camera may not go far into it.
- Locking off that zone leaves more of the frame for what matters to the gameplay.
8:16 Juice
Camera effects such as shake, freezes and zooms make a game feel more exciting and alive.
- Screen shake sells explosions, impacts, struggles and heavy monsters. 8:23
- You can tune both its intensity and its direction.
- Celeste wobbles the camera in the direction of Madeline's dash, which sells the speed and power of the move.
- Hit stop adds a tiny freeze frame that makes hits feel stronger. 8:48
- In Katana Zero, killing an enemy freezes the action for a split second.
- The camera still shakes and particles still ring out, but the action is frozen before it restarts.
- Hollow Knight stalls the camera for a long time when the player takes a hit. This makes the mistake register and gives a moment to recover.
- A short zoom or move can add excitement to key events. 9:33
- In Dave the Diver, landing a catch zooms in on the battle between Dave and the fish, then returns to normal.
- Fast shaking and moving can trouble some people, so an option to turn off screen shake is a nice touch.
9:55 Conclusion
A camera's core job is to keep the hero on screen, and the techniques above let it do much more.
- Each camera technique answers a different need, and the game decides which ones to use. 10:26
- A slow, pensive platformer needs a very different camera from a twitchy, erratic arcade thrill ride.
- Platformer Toolkit has a camera panel where you can tweak damping, zoom, lookahead and whether jumps are ignored.
In the growth library
Mark Brown, creator of Game Maker's Toolkit. A 2D camera should do far more than stick to the player: it should show what is coming, ignore jumps, smooth its motion, frame important things, and add juice. The tour of Cave Story, Donkey Kong Country: Tropical Freeze, Fez, Insanely Twisted Shadow Planet, Celeste and Hollow Knight shows how each camera rule fits its game.
More from Game Maker's Toolkit · The whole library, and ask it anything