Skip to content

Tutorials · Cameras and Framing · Chapter 5

The town’s walls

30 minutes Uses: Confiner, CameraRig, PixelPerfect

By the end

  • A Confiner on a node of its own, town-walls, whose Bounds run from the town’s west wall to its east wall and from under the street to 240 above it
  • The castle given the town’s camera, copied and pasted, its Subject picked again and its Pixel Perfect’s reference 256 by 144
  • Five rooms under one node, rooms, a Confiner each, and the view sliding from one to the next over each room’s Blend
  • What Problems says about a Confiner on the camera’s own node, and about two rooms laid over each other
On this page

The town’s walls

The rig follows the watchman wherever he goes, and past the town’s walls too. At his start the view shows 64 units of Background west of the west wall, since the rig centres him and the wall is only 64 from him:

The game at the watchman’s start, chapter 4’s camera: night blue down the left of the picture, then the west wall’s dark stone, then the street running right with the watchman in the middle
Chapter 4 at his start: night blue west of the wall.

A Confiner is a rectangle the view is kept inside: a room. The rig still moves the camera; the Confiner then holds the picture so no part of it shows past the rectangle.

  1. In the Hierarchy, select town. Press + Add node and choose Camera Confiner. It lands under town, last. Rename it town-walls.
  2. Set its Position to 1280 and -56: the middle of the rectangle.
  3. In its Confiner, set Bounds to 2624 and 368. Leave Blend at 0.
  4. Press Ctrl+S.
The town framed whole at 31.3%, town-walls selected: a rectangle with a square at each corner round the whole street from the west wall’s outer face to the east wall’s, from well above the street to the bottom of its stone, the label town-walls at its middle; the camera’s frame and the rig’s boxes small at the west end; the Inspector shows Position x 1280.0 and y -56.0 and the ConfinerComponent: Bounds 2624.0 and 368.0, Blend 0.00 s
town-walls selected: its Bounds round the street, wall to wall.

The Bounds are centred on the node: 2624 across from 1280 is x -32 to 2592, the west wall’s outer face to the east wall’s; 368 down from -56 is y -240, 240 above the street, to 128, the underside of the street’s stone. The view never shows past the walls, nor more than 240 above the street.

The game at the watchman’s start, with the Confiner: the west wall’s dark stone at the very left edge of the picture, the street running right, the watchman left of the middle
With town-walls: the view starts at the wall’s outer face, and the watchman is left of the middle.
The game: the watchman walks east from the west wall, the view leaving the wall behind, then turns and walks back west; the view comes back with him and stops with the wall at its left edge while he walks on to the wall
The Confiner at the west wall. Watch the wall on his way back: the view stops with the wall at its edge, and he walks on to it.

At his start the camera’s node is where the rig wants it, at his framed point; the room holds the camera 64 units east of it. Left to the rig alone, the view would show 123 units past the wall’s outer face once he stood against it. At the street’s east end he never reaches the wall: the castle door, in the gatehouse passage, takes him into the castle first. The view reaches the east wall’s outer face all the same, a view’s width before him.

The Camera tab a second into Play at the town’s west end: Camera camera, At rest 128.0, -24.0, As drawn 128.0, -24.0, Node at 64.0, -24.0, Rotation 0.0°, View 320 × 180 units, Zoom 4.00 px a unit (Pixel Perfect 4 × Zoom 1.00), camera_view() left -32.0, top -114.0, right 288.0, bottom 66.0; Room: Held by town-walls, Clamping On x, Blend None; Rig: Shot follow, Blend None
The Camera tab at his start: Held by town-walls, Clamping On x. The node is at 64; the camera rests at 128.
Bounds
The room’s size, across and down, in world units, centred on the Confiner’s node. The view is kept inside it. A room narrower or shorter than the view centres the view on it that way instead. Selected, the Confiner draws its Bounds, and each corner is a handle: drag one to resize the room.
Blend
Seconds the view takes to slide into this room when the camera arrives in it from another. 0, as it comes, cuts. The town is one room, so it never slides; the castle’s rooms use it.
The Camera tab’s Room rows
Held by, the room holding the camera, or No room; Clamping, whether the room is holding the view in, and on which axis: On x, On y, On x and y or No; Blend, a slide into the room under way, from which room and how far, or None.
The Problems tab with one warning on camera: This Confiner is on the camera "camera", so the room moves with the camera and never holds it — move the Confiner onto a node of its own that stays still, not on the camera
A Confiner added to camera itself: one row in Problems.

The castle’s camera

The castle has had no camera. It gets the town’s, rig and all, by copy and paste: the clipboard keeps what you copy when you open another scene.

  1. In the town’s Hierarchy, right-click camera and choose Copy.
  2. In Assets, open scenes and double-click castle.ron.
  3. Right-click castle and choose Paste as child. The camera lands under castle, last, at 64, -24, as the town’s stands: his framed point at the great hall’s west end, where he comes in.
  4. In its rig’s framing, the Subject reads (missing #9) in red: it still points at the town’s watchman, who is not in this scene. Click Subject and choose this scene’s watchman.
  5. In its Pixel Perfect, set Reference Width to 256 and Reference Height to 144.
  6. Press Ctrl+S.
The castle’s camera selected and looked through, the game not running: the great hall’s west end, the hall’s stone wall a quarter of the way in with the night-blue Background to its left and under the floor, its mossy floor across the rest of the bottom, the watchman standing by the wall, the rig’s circle and boxes on his feet and its larger box round him; the Hierarchy lists castle with tiles, watchman and camera; the Inspector shows Position x 64.0 and y -24.0
The castle’s camera: the great hall’s west end, 256 by 144.

The castle’s rooms are smaller than the street, so the reference is too: 256 by 144, which a 1280 by 720 window shows at 5 screen pixels to an art pixel. The Camera, its rig and its framing are the town’s, but for the Subject; its Scaling, Extent and Width are the town’s Letterbox, unread under the Pixel Perfect as before.

Nothing holds the view yet. It is drawn from where the camera rests, at his framed point, so it shows 64 units of Background west of the hall’s wall and a strip under its floor, as chapter 4’s did west of the town’s wall. The rooms below hold it.

The game in the castle a second after it opens, with no room yet: night-blue Background at the left, then the great hall’s stone wall, its mossy floor across the rest of the bottom with a strip of night blue under it, the watchman standing by the wall, large, and the same night blue behind him
The castle as it opens, with no room yet: the great hall, 256 by 144 at five pixels to an art pixel, and the Background past its west wall.

A room for each hall

One scene can hold several rooms, each a Confiner. The camera is held by the room whose Bounds hold its node, and when its node walks into the next room the view slides into it over that room’s Blend. The castle has five rooms, in a row, each a rectangle of its own; they meet at their walls and never overlap.

  1. Select castle. Press + Add node and choose Node. Rename it rooms, and leave it at 0, 0.
  2. Select rooms, press + Add node and choose Camera Confiner. Rename it great-hall, set its Position, Bounds and Blend from the table below.
  3. Do the same for stair-shaft, cistern, lens-room and beacon-room, each under rooms, in that order.
  4. Press Ctrl+S.
Node, under roomsPositionBoundsBlend
great-hall320, -96640, 2560
stair-shaft736, -336192, 7360.6
cistern1024, -576384, 2560.4
lens-room1408, -624384, 3520.4
beacon-room1792, -768384, 2561
The castle framed whole at 41.4%, tiles selected: the great hall at the bottom left, the tall stair shaft rising from its east end with ledges up it, the cistern east of the shaft’s top, the lens room beyond it with a long ledge under its ceiling, and the beacon room east of that, a level up; each room outlined thin, with a small cross at its middle, the watchman small at the hall’s west end with the camera’s frame and the rig’s boxes round him
The castle, framed: five rooms, each outlined by its Confiner, the crosses at their middles.

Each room is the rectangle of its hall, walls and floor and ceiling, and each Confiner sits at its rectangle’s middle with the rectangle’s size for its Bounds. The great hall is first in the Hierarchy, so it holds the camera as the castle opens, the view stopped with the hall’s west wall at its left edge. The stair shaft is 192 wide, narrower than the view’s 256: in it the view is centred across the shaft, and shows 32 units beyond it either side.

The game: the watchman walks east along the great hall’s floor while the view holds still, then the view slides right and the stair shaft’s ledges and its east wall come into the picture; at the end he leaps up towards the first ledge
From the great hall into the shaft. Watch the floor: the view holds at the hall’s east end, then slides into the shaft over 0.6 seconds.

The hall holds the view with its east edge on the hall’s, x 640, until the camera’s node crosses into the shaft. Then the view slides from the hall’s hold, its middle at x 512, to the shaft’s, at 736, over the shaft’s Blend: 0.6 seconds, 36 steps, easing in and out, the watchman in the picture all the way. The cistern’s slide and the lens room’s take 0.4 seconds, 24 steps; the beacon room’s takes 1 second, the slow one, for the room at the top.

The Camera tab in Play in the slide: Camera camera, At rest 633.3, -40.0, As drawn 633.3, -40.0, Node at 692.3, -24.0, Rotation 0.0°, View 256 × 144 units, Zoom 5.00 px a unit (Pixel Perfect 5 × Zoom 1.00), camera_view() left 505.0, top -112.0, right 761.0, bottom 32.0; Room: Held by stair-shaft, Clamping On x and y, Blend From great-hall, 53%; Rig: Shot follow, Blend None
The Camera tab in the slide: Held by stair-shaft, Blend From great-hall, 53%.
The game: the watchman leaps up the stair shaft from ledge to ledge, four leaps; the view rises after him, centred across the shaft, its walls at the picture’s edges once he is above the hall
Up the shaft, four leaps. Watch him against the picture’s top: his body stays in the picture through every leap.

The castle’s view is 144 tall, not the town’s 180, and the shaft is climbed by leaps. Through four leaps the view stays centred across the shaft and inside it, his feet are never within 40 of the picture’s bottom, and his body never leaves it. At the start of each leap the top of his head goes over the picture’s top, by 5.3 units at the worst: the lead is what holds the rest of him in. With no lead it goes 16.3 over.

A room is chosen by where the camera’s node is, not by where he is, and the node is where the rig has got to: a little behind him or ahead of him. Going up, it is behind: when he leaps, the node follows a moment later. So no line between two rooms could hold him in the picture across a leap up through a floor, and every way between the castle’s rooms crosses a wall instead. The way into the beacon room is a door at floor level, at the end of the lens room’s gallery, 300 units long: long enough for him to get up to his walk, so the camera is ahead of him at the wall. Crossing that door, the tightest the picture gets on his body is 6 units from its east edge.

The Problems tab with one warning on stair-shaft: This room overlaps "great-hall" and neither has a Blend, so in the overlap the camera stays with whichever room held it last and the view cuts when it leaves that one — move the rooms apart so they only meet at a wall, or give one a Blend
The shaft’s Bounds made 100 wider, over the hall, and its Blend 0: one row in Problems.

A rolled view in a room

A view that is tilted is kept inside its room by all four of its corners, not only its middle. Chapter 8 tilts the camera; to see it now, tilt the castle’s, and put it back.

  1. Select the castle’s camera. In its rig’s framing, set Rotation to 11.46.
  2. With castle.ron open, press F5, and F5 again to stop.
  3. Set Rotation back to 0, and press Ctrl+S.
The castle camera’s Inspector narrowed with the search box, camerarig, to its CameraRigComponent: Enabled ticked, Framings with its row 1 follow open: Name follow, Subject watchman, Active ticked, Priority 0, Zoom 1, Rotation 11.46°
The framing’s Rotation, 11.46°.
The game in the castle with the view tilted: the great hall’s west wall a dark slanting band at the left, the floor’s mossy stones running up to the right on a slant, the watchman standing near the wall, cut by the picture’s bottom-left corner
The framing’s Rotation at 11.46°: the tilted view’s corners inside the hall, its west corner on the wall.

The Inspector shows Rotation in degrees, two decimals. The tilted view needs more room than a level one, so the camera rests further from the wall than it would level, and the corner nearest the wall touches it.

Who moves the camera

The rig, every step, as in chapter 4: it moves the camera’s node after the watchman. Then the room holding the node holds the picture: it clamps where the camera rests so no corner of the view shows past the room, and slides it from one room to the next over a Blend. The rig follows him; the rooms only hold the picture. The Camera tab shows both: Node at, where the rig has put the node, and At rest, where the room holds the camera.

The walls and the rooms

SceneNodeComponentFieldValue
towntown-walls, last under townNodePosition1280, -56
ConfinerBounds2624, 368
Blend0, as it comes
castlecamera, the town’s pasted under castleNodePosition64, -24
Camera Rig, framing followSubjectthe castle’s watchman
Pixel PerfectReference Width, Reference Height256, 144
rooms, a Node under castleNodePosition0, 0
its five roomsConfinerPosition, Bounds, Blendthe table above

Check it works