Okay - let's say you're making a 2D game and you need some kind of camera to frame the action. No problem - just pin the camera to the main character, right?
Wrong!
Do this and you'll have a camera that's jittery, jumpy, short-sighted, and boringly static.
So let's fix it. Here are five quick tips for making a much better 2D camera.
Lookahead
First, let's talk about lookahead.
Basically - if you keep the character in the middle of the screen at all times then you're dedicating just half of the display to the stuff that's in front of you. No surprise, then, why it’s so easy to run into spikes in the old Sonic games.
So it might be better to focus more attention on the stuff that coming up, and ignore the stuff behind you. And there are a few ways to do it.
The simple solution is to simply zoom the camera out further. That means even if the hero is dead centre on the display, you can still get a good view of what's to come.
A more involved solution, though, is to shift the camera in front of the character.
If you can only move in one direction it's enough to simply offset the camera from the main character. That's great for endless runners and the like. But if the player can travel both left and right then you'll need to adjust the lookahead based on the direction of travel.
So in Cave Story there are two camera positions - one when you're moving left and one when you're moving right. They're both offset in front of the player, which is perfect for a game about shooting targets in front of you. When you swap direction, the game slowly glides to change from one position to the other.
New Super Mario Bros. U does something similar. The camera is naturally biased on the right side of the screen, ahead of Mario. But if you start to backtrack for a short period of time the camera will realise, catch up, and swing further left of Mario.
And in Sonic Generations the camera reacts to Sonic's speed. It settles on the hedgehog when he's stood still, but it moves further and further in front of him as he picks up momentum - until it reaches a maximum position.
This is not just for platformers, though - in Hyper Light Drifter, the camera is offset a few feet in front of the hero's head so no matter which direction you're facing, the camera will frame what's coming up. And in Luftrausers the camera tracks in front of the player's plane - but only when the throttle is held down. That makes it possible to do those sexy stall-and-swing-around shots, without losing sight of your prey.
It's even easier to do this if the player has a method for aiming, like in Nuclear Throne. By centring the camera somewhere between the character and the cursor, you can get a better look at the enemies you're shooting at. It's a very natural way of responding to the player's intention and framing what they obviously want to see. You can witness similar stuff in bullet-based roguelike Enter the Gungeon, clone 'em up puzzler The Swapper, and blood-soaked rampager Hotline Miami.
Basically - ask yourself "what does the player really need to see"? And then make sure the camera isn't hiding it.
Jumping
Next up - let's talk about cameras and jumping. Because if you pin the camera to the character then it's going to move the screen every time you jump. And if you're making a platformer - a genre that's all about jumping - that's a lot of camera movement.
This can make the player feel nauseous, and make it hard to line up perfect jumps - especially if the platforms disappear beneath the camera when you lurch upwards.
So, there are two main ways to help with this.
One is to ignore jumps until the player reaches a certain elevation. In Donkey Kong Country: Tropical Freeze the camera doesn't react to DK's leaps - ensuring that the ground stays in the same position at all times.
However, when you land on a sufficiently high platform, the camera tracks up and sets a new baseline to work with. This means that the camera moves when you've landed, rather than shifting mid jump. The camera can break these rules in certain circumstances, like when you're climbing a rope or swimming - now it moves up and down freely.
Rayman Legends is similar: the frame doesn't need to lurch up when Rayman jumps. It can just track up in certain, predetermined areas where the level goes beyond the frame.
The other way to fix this is through the level design itself.
In a game like Shovel Knight, the levels are designed with a maximum height - which just so happens to be the exact height of the screen. This means that the camera only needs to track left and right, but never needs to move up and down - allowing the camera to stay still for jumps.
Go even further and you can keep the entire level in a single screen, which means the camera doesn't need to move at all. Which is perfect for precision jumping.
It also helps to offset the camera vertically, so the hero is closer to the bottom of the screen. This gives more vertical space to play with and less need to move the camera up and down.
But perhaps the best tip to remember is that you don't need to treat both camera axes equally - it can do completely different things when moving left to right, and when moving up and down.
Damping
Next - let's talk damping. If the camera perfectly tracks the character then it's going to react to every single movement, no matter how small - and that can lead to a camera that feels erratic and jerky. Especially when making precision movements to line up a perfect jump.
One solution is to use damping - simply have the camera ease between its current position and the character's position. This will make it follow events more smoothly, and won't immediately respond to small shifts in position.
Though, be aware: if the camera is slow to catch up to the player's movements you can end up with moments where the character is actually in front of the camera, leaving even less screen real estate for looking ahead.
Another solution is to impose some kind of dead zone.
In Fez there's an invisible window where the character can wander around freely without the camera moving at all. But if you push beyond that window, the camera shifts. This does mean that the character will be far beyond the centre of the screen when walking - but the camera is so zoomed out in this game that it doesn't really matter.
Super responsive cameras can be good for retro-inspired titles that want to capture that choppy 8-bit feeling, but otherwise even a tiny bit of camera damping can make things feel more smooth and polished.
Framing
Now, the camera should usually be focused intently on the character - but you'll sometimes want to frame other things, too. So don't be afraid to move, zoom, or halt the camera.
For instance, you can use the camera to draw the player's attention to certain objects. In the game Insanely Twisted Shadow Planet, key areas like checkpoints and puzzle zones have a sphere of influence around them. If the player's spaceship enters the sphere, the camera is told to find the average position between the key area and the spaceship - framing both on screen and adeptly drawing the player's attention.
The camera can also temporarily frame a scene. Disney Illusion Island typically just follows Mickey's movements, but it can also zoom out and settle on a predetermined position to completely frame a tricky platforming section or puzzle area. When the player leaves, it goes back to normal tracking.
The camera may sometimes need to follow multiple things, too. In the fantasy basketball RPG Pyre, the current character is equally as important as the ball - so the camera zooms and moves in an attempt to make sure both are prominent on screen simultaneously.
You may also want to move the camera for dramatic, cinematic-style framing. In Inside, the camera usually just tracks ahead of the player like a normal platformer - but at key moments, like when you're being chased by a pack of rabid dogs - the camera moves for a better view of your attacker.
You can also zoom the camera in and out for effect. In GRIS, the camera sometimes tightly frames the hero, and sometimes draws right out to reveal the grand scale of a building.
And you can also restrict the camera from looking at certain things. Spelunky levels are surrounded by an impenetrable rocky picture frame - and the camera is forbidden from going too far into this zone. By locking off this section it means more of the frame can be focused on stuff that's actually relevant to the gameplay.
Juice
Finally, the camera can also be used to add juice. To make the game feel more exciting and alive.
For starters there's screen shake. The ancient art of simply... wobbling the camera around. This can be an effective way to sell an explosion, an impact, a frantic struggle, or a heavy-footed boss monster. You can tweak the intensity - and also the direction. In Celeste, the camera wobbles in the same direction as Madeline's dash, to really sell the speed and power of her special move.
There's also hit stop. This is about adding a small freeze frame to the game - which can subconsciously increase the impact of an action. Check out Katana Zero - when you kill an enemy the action freezes for a split second. The camera still shakes and some particle effects still ring out - but the action is frozen in time, before starting back up. When playing at normal speed this small hitch in the action makes every hit feel more impactful.
In Hollow Knight, the camera stalls for a long time when you, the player, take a hit - which makes sure you register the mistake, and gives you a brief moment to collect yourself.
And finally, the camera can move and zoom for a short period to add further excitement. In Dave the Diver, when you land a catch the camera will suddenly zoom in and frame the epic battle between Dave and fish, before returning to normal.
All of these techniques add juice - but quickly shaking or moving the camera can be troublesome for some people so providing accessibility options - like turning off screen shake altogether - is a nice touch.
Conclusion
So to wrap it up - the camera's job is ultimately to follow the main character and keep them on screen at all times. But it can do so much more than that.
It can look ahead to focus on upcoming challenges. It can ignore jumps to avoid endless movement. You can add damping to smooth things out. Use special rules to feature and frame important events. And make quick adjustments for impact and effect.
But remember that there's no such thing as a perfect camera that works for every game. it depends entirely on the thing you're making. A slow and pensive platformer needs a very different camera to a twitchy, erratic arcade thrill ride.
But hopefully these tips give you some good ideas for your own camera. You can play with some of these concepts yourself in my interactive video essay Platformer Toolkit, where you'll find a whole panel dedicated to the camera. You can tweak the damping, zoom in and out, add some lookahead, and choose whether or not to ignore jumps.
Thanks for reading and I'll see you soon!