Spielerando

Room Camera

A room camera cuts the world into screen-sized rooms and shows the one the character is in. It does not follow the character inside a room. When the character crosses into the next room, the camera slides over in a set time. When the character lands far away, the screen fades out, moves, and fades in.

Also called: Screen-by-screen camera, Fixed-screen camera, Room transition.

A small robot lamplighter steps through a doorway between two lit rooms of a cutaway lighthouse while a bright translucent frame the size of one room slides from the left room to the right one.
Lanternhutch Nights, an invented dollhouse puzzle adventure. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Room Camera" to my game.

What it should do: Showing one whole room at a time gives the designer full control of what the player sees, makes puzzles and ambushes fair, and removes the need for the camera to guess. The player always knows where the edges are.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> settled
  settled: Settled
  sliding: Sliding
  cutting: Fading
  settled --> sliding: enters next room
  sliding --> settled: slide is done
  settled --> cutting: lands far away
  sliding --> cutting: lands far away
  cutting --> settled: fade is done
```

Use these starting values:
- roomWidth: 16 units
- roomHeight: 9 units
- slideTime: 0.5 s
- cutTime: 0.4 s
- margin: 0.4 units

Watch out for these common mistakes:
- Rooms at negative positions: Tell your AI: find the room by rounding down, never by cutting off the decimals.
- Standing on a doorway: Tell your AI: let the character go a small distance into the next room before the camera goes, and the same distance back before it returns.
- The corner: Tell your AI: work out the room for both directions together and slide once, straight to it.
- A far jump: Tell your AI: for anything more than one room away, fade out, move and fade in.
- A long frame: Tell your AI: measure the slide in time, and put the camera exactly on the room at the end.
- Running on during a slide: Tell your AI: when a slide ends, look at the character again and slide on if it is in another room.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Showing one whole room at a time gives the designer full control of what the player sees, makes puzzles and ambushes fair, and removes the need for the camera to guess. The player always knows where the edges are.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

enters next roomslide is donelands far awaylands far awayfade is doneSettledSlidingFading
How it runs, as a diagram
  • Settled → Sliding: enters next room
  • Sliding → Settled: slide is done
  • Settled → Fading: lands far away
  • Sliding → Fading: lands far away
  • Fading → Settled: fade is done

Good starting values

ValueStart withWhat it changes
roomWidth16 unitsThe width of one room, the same as the width of the screen. Every room is the same size.
roomHeight9 unitsThe height of one room, the same as the height of the screen.
slideTime0.5 sHow long the slide from one room to the next takes. Half a second is quick enough not to feel like a wait and slow enough to see where you went.
cutTime0.4 sThe whole fade for a far jump: black by the half, clear again at the end.
margin0.4 unitsHow far into the next room the character must be before the camera goes, and how far back to come back. It stops a camera that flips when the character stands on a doorway.

What usually goes wrong

Rooms at negative positions

Cutting off the decimals instead of rounding down puts the positions from minus one to one into the same room, so the room at the origin is twice as wide, and the camera jumps strangely there.

Fix: Tell your AI: find the room by rounding down, never by cutting off the decimals.

Standing on a doorway

A character standing exactly on the border, or moving a little back and forth over it, makes the camera slide to one room and back, again and again.

Fix: Tell your AI: let the character go a small distance into the next room before the camera goes, and the same distance back before it returns.

The corner

A character that passes a corner between four rooms can trigger two slides in a row, one sideways and one up, and the camera zigzags.

Fix: Tell your AI: work out the room for both directions together and slide once, straight to it.

A far jump

A slide to a room ten rooms away sweeps through every room between at a crazy speed, or takes too long if the time is stretched with the distance.

Fix: Tell your AI: for anything more than one room away, fade out, move and fade in.

A long frame

If the slide moves a fixed amount per frame, a long frame goes past the new room and the camera overshoots, or the time depends on the frame rate.

Fix: Tell your AI: measure the slide in time, and put the camera exactly on the room at the end.

Running on during a slide

The character keeps running during a slide and is already in the room after the next one when it ends. If the game forgets this, the camera stays one room behind.

Fix: Tell your AI: when a slide ends, look at the character again and slide on if it is in another room.

How to check it works

Works well with

Clashes with Camera Look-Ahead: A look ahead inside a room would show a strip of the next room or empty space. Use one of them. In a game with rooms, set the look distance to zero.

Clashes with Camera Dead Zone: A box that lets the camera drift inside the room fights the fixed view. Use the dead zone in open levels and the room camera in room-based ones.

Common questions

what do i tell my ai to add a room camera

Paste this: Add a room camera: cut the world into rooms of 16 by 9 units, show the room the character is in, and slide to the next room in half a second when the character is 0.4 units into it. For a room more than one away, fade out, move and fade in. Find rooms by rounding down.

how does a screen-by-screen camera work

The world is a grid of rooms the size of the screen. The camera sits in the middle of the current room and stays there. It moves only when the character walks into another room, by sliding across.

why does my room camera jump back and forth at the door

The character is standing on the border and the room changes with every tiny move. Make the character go a small distance into the next room before the camera goes, and the same distance back before it returns.

why is my room at the origin twice as big

The room is probably found by cutting off decimals. Numbers just below zero then land in room zero, together with those just above. Use rounding down.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it