Spielerando

Camera

Learning paths through this topic

The camera shows empty space beyond the level edge, or shakes in a small room

Near the edge of a level the view slides out and shows the void behind it. The plain fix breaks when the level is smaller than the screen or the zoom changes, because the limits depend on how much is visible. Here is the correct limit and what to do in tiny rooms.

The shot goes to the wrong place when the camera is zoomed or moved

Aiming works perfectly with a fixed camera and falls apart the moment the view scrolls, zooms or the window is resized: the mark and the click disagree by a growing distance. The conversion between screen and world needs three details that are easy to forget.

Pixel art flickers or shows thin lines while the camera moves

When a camera glides over pixel graphics, edges shimmer, tiles show hairline gaps and the player seems to vibrate against the background. The cause is positions between whole pixels. Here is how to round the right things at the right moment so that everything moves as one.

The view bobs up and down with every jump, which feels like seasickness

If the camera follows the character vertically, each jump moves the whole world and makes it hard to judge landings. Following only when the character is on solid ground still loses it on long falls. Here is the combination of the two and the different speeds that feel right.

A camera that jumps from room to room when the player crosses the edge

Games built from separate screens need the view to change when the player walks out of one. Done naively it flickers back and forth on the boundary, lets enemies move while the picture slides or catches the player half outside. Here are the room rule, the slide and what freezes.

The building preview sits half a tile off the cursor for some sizes

When you place a building, the see-through preview should sit exactly where the mouse is, whatever its size. Small and large, odd and even footprints all look right in different ways, and the easy rounding is right for only some of them. Here is one formula that fits all, with the map border.

Saved camera spots on number keys, and a way back to where I was

Players want to save a few places on the map and jump to them, but after the jump they often cannot find their way back. Here is how a saved spot should remember zoom as well as place, what the same key does the second time, and the trap when you nudge the view after arriving.

The camera flies to every event and cannot be stopped, or never returns

Story moments, new quests and big fights can all want the camera at once. Without rules the view jumps around, ignores the player's hands, or leaves them somewhere strange. Here are the rules for which event wins, who may interrupt, and when and where the camera goes back to.

Scrolling over hills makes the 3D camera dive into the ground or bounce up and down

A camera that keeps a fixed height above the ground under it follows every bump of the terrain, and one that ignores the ground goes through hills. Here is how to look at the ground around the spot instead of at one point, how fast to go up and down, and a floor that is never broken.

The camera freezes when I pause and lags behind units at fast-forward

Strategy games let you pause and speed up the world, and the camera is caught in the middle. Run it on game time and it stops with the pause; run it on real time and a fast-forward leaves a followed unit far outside the screen. Here is which clock each part uses and the one change that fixes the lag.

On a diamond-shaped map the camera can drift into the empty corners

Keeping the camera inside a rectangle works for a flat map, but a slanted-view map is shaped like a diamond, and a rectangle leaves large empty triangles where the view floats over nothing. Here is a way to keep the camera on the map that also lets it slide along the border instead of sticking.

Units flip between icon and full detail back and forth while I hold one zoom

Zoomed out, a thousand units should be small symbols; zoomed in they should show full detail. Where the switch happens, the picture flickers back and forth at the slightest shake of the wheel. Here is the rule that makes each switch happen once and what happens when the zoom jumps over several levels.