Topics / Building a game

Core concepts

Camera and viewport

The camera decides which part of the world is on screen and from what angle. The viewport is the rectangle it draws into. Zooming, following the player and screen shake are all camera changes.

Watch: see it in 30 seconds

Video coming soon
A 30-second visual explanation

Why it matters for your game

  • 'Follow the player' and 'zoom out when the village is big' are camera requests; they do not change the world at all.
  • In 2D the camera is a rectangle sliding over the map; in 3D it has position, direction and field of view. A village game usually uses an isometric-style angle for its 3D scene.
  • Screen coordinates (pixels on the display) and world coordinates (positions in the village) are different; converting between them is what clicking on things needs.

How it comes up when you talk to your AI

  • 'Orthographic' (no perspective, flat 2D or isometric), 'perspective', 'field of view', 'follow', 'bounds' (the camera stops at the map edge), 'screen to world'.
  • When the map shows black edges, the camera bounds are missing; when the UI drifts with the map, it is drawn in world space instead of screen space.

Ask your AI about it

Paste this into the assistant you build with. It is written to get a useful answer for your own project, not a textbook page.

Explain cameras in a 2D and a 3D game: orthographic versus perspective, following the player, bounds, and screen versus world coordinates. Show how to make the camera follow a villager smoothly and stop at the map edge.

Related terms