Skip to content

Tutorials · Cameras and Framing · Chapter 4

Following

30 minutes Uses: Camera, CameraRig

By the end

  • The camera made the watchman’s child, and why a camera that follows to the pixel is not what a game wants
  • A Camera Rig on the camera with one framing, follow, whose Subject is the watchman: a Dead Zone of 24 by 16, a Soft Zone of 96 by 64, an Offset of 0, 24, Damping of 0.35 and 0.5, and a lead of Time 0.6, Smoothing 0.6 and Limit 80
  • The rig’s gizmo and handles in the Viewport, and its rows in the Camera tab
  • Who moves the camera now, and the Problems row for a Zoom typed where the rig sets it
On this page

A camera that is his child

A camera is a node, and a node goes where its parent goes. So the plainest way to follow the watchman is to make the camera his child. Try it, and do not keep it.

  1. In the Hierarchy, drag camera onto watchman. It becomes his child.
  2. Set its Position to 0 and -40: a child’s Position is from its parent, here his feet. With the Camera’s Offset of 16, the picture is drawn from 24 above his feet.
  3. Press F5. Walk east with D and leap with Space on the way. Press F5 again to stop.
The game with the camera as the watchman’s child: he runs east along the street and leaps three times; he stays in the middle of the picture, and with every leap the whole street drops out of the bottom of the picture and comes back
The camera as his child. Watch the street at each leap: it jerks down out of the picture and back, since the camera is held to his every move.

He never moves in the picture: the world does, all of it, at once. Every leap throws the street down and back up. A camera operator does not film that way: they let the subject move a little before they follow, ease after him, and keep the room ahead of him in the shot. That is a Camera Rig.

  1. Drag camera back onto town. It lands under it, last, as it was.

A Camera Rig

A rig holds one or more framings, each a shot with a subject and its own settings, and moves the camera’s node to where its live framing wants it, every step. The town needs one framing, on the watchman.

  1. Select camera. Set its Position to 64 and -24, and the Camera’s Offset back to 0 and 0.
  2. Press Add component and choose CameraRigComponent. It goes on the camera’s own node, after the Pixel Perfect: it moves that node.
  3. Next to Framings, press +. A framing appears; open it with its arrow.
  4. Set Name to follow: its row then reads 1 follow. Click Subject and choose watchman from the list, or drag watchman from the Hierarchy onto it.
  5. Leave Active ticked, Priority 0, Zoom 1, Rotation 0°, Duration 0.50 s and Ease EaseInOut, as they come.
  6. Set Dead Zone to 24 and 16, Soft Zone to 96 and 64, Offset to 0 and 24, and Damping to 0.35 and 0.5.
  7. Under them, set Time to 0.6, Smoothing to 0.6 and Limit to 80.
  8. Press Ctrl+S.
The camera’s Inspector narrowed with the search box, camerarig, to its CameraRigComponent: Enabled ticked; Framings, 1 items, its row 1 follow open: Name follow, Subject watchman, Active ticked, Priority 0, Zoom 1, Rotation 0°, Duration 0.50 s, Ease EaseInOut, Dead Zone 24.0 and 16.0, Soft Zone 96.0 and 64.0, Offset 0.0 and 24.0, Damping 0.35 and 0.5, Time 0.60 s, Smoothing 0.60 s, Limit 80.00 u; and the Cut to live framing button
The rig and its one framing, follow, with camerarig typed into the Inspector’s search box.

The framing’s Offset is where in the picture he sits, from its middle. The rig aims the camera at his place, less the Offset; y grows downward, so 0, 24 puts him 24 below the middle, and the picture’s middle 24 above his feet. That is enough that the lit furnace by the gate is whole in the picture when he stands beside it. The node is put at his framed point, his place 64, 0 less the Offset, so the rig starts on him and the first frame has nothing to catch up: a view of 320 by 180 round 64, -24, from x -96 to 224. The west wall is at x -32 to 0, so 64 units of Background show west of it, until chapter 5 stops the view at the wall.

The rig’s Enabled
Whether the rig drives the camera. Ticked, as it comes. Unticked, the camera rests where its node stands, as it did in chapters 1 to 3.
Framings
The rig’s shots, each a row: + adds one, the arrows reorder them and the bin removes one. The highest Priority among the active ones is live, wherever it sits; their order matters only between two of equal Priority, and then the one higher in the list is live. The Cut to live framing button under them is chapter 7’s.
The framing’s Name
What it is called, here follow: the Camera tab names the live shot by it, and a script switches framings by it in chapter 7.
Subject
The node the framing follows: the watchman, picked from the list or dragged from the Hierarchy. A framing with no subject holds a fixed point.
The framing’s Active
Whether this framing is in the running for the camera. Ticked, as it comes.
Priority
Which active framing is live: the highest. 0, as it comes; with one framing it never matters. Chapter 7 adds a second.
The framing’s Zoom and Rotation
The Camera’s Zoom and Rotation while this framing is live: the rig writes them onto the Camera every step, so the Camera’s own are 1 and 0° and stay so. 1 and 0°, as they come. Rotation is in degrees in the Inspector. Chapter 7’s vista zooms out this way.
Duration and Ease
The Blend into this framing from whatever was live: how many seconds it takes, 0.50 s as it comes, and the shape of the move, EaseInOut as it comes. With one framing there is nothing to blend from, so they never run. Chapter 7 sets them.
Dead Zone
How far, across and down, he may move from where he is supposed to sit, the middle of the picture moved by the framing’s Offset, before the camera follows: 24 by 16, in world units. The box tests his point plus the lead, which is not drawn: with this framing’s lead the camera first moves when he has walked 16 units into its 24, on the sixth step of a walk, the lead making up the rest. A step is a sixtieth of a second, the game’s own tick.
Soft Zone
How far he can ever get from where he is supposed to sit, across and down: 96 by 64. However fast he goes, even a dash of 300 in one step, the camera is pulled along to keep him inside it. 0, as it comes, is no limit: only the Damping decides how far the camera lags.
The framing’s Offset
Where in the picture he sits, from its middle: 0, 24, 24 below it. His feet are his place, so his feet are 24 below the middle, with the street’s sky above him.
Damping
The seconds the camera takes to close nine tenths of the gap to where it wants to be, across and down: 0.35 across and 0.5 down, so after a leap the view settles more slowly than it follows a walk.
Time
The lead: seconds of his motion the camera aims ahead by. 0.6 at his 160 a second asks for 96 units ahead of him. 0, as it comes, is no lead.
Smoothing
Seconds over which the lead itself eases in and out, so the camera does not swing the moment he starts, stops or leaps. His leap starts at 680 units a second upward, nearly all of the lead for a moment; 0.6 keeps that from throwing the camera up and down faster than the leap. After a leap the view rests 28 to 29 above his feet.
Limit
The largest lead, in world units: 80. Time’s 96 is cut to 80, so it is the Limit that holds the lead on a run. 0, as it comes, is no limit.

The rig in the Viewport

  1. With camera selected, press Look through.
camera selected and looked through, the game not running: the watchman standing on the street’s cap, the west wall’s dark stone at the left; on his feet a small circle labelled follow with a square at its middle, round it a small box, and round that a large box reaching from above his head to the ground, each box with a square at every corner; the camera’s cross above his head; the Inspector shows Position x 64.0 and y -24.0, the Camera with Offset 0.0 and 0.0, and the CameraRigComponent below
The rig’s gizmo, the game not running: the mark on his feet, the dead zone round it and the soft zone round that.

Selected, a rig draws its live framing where he is supposed to sit: a circle labelled with the framing’s name, the middle of the picture moved down by the Offset, here on his feet; the Dead Zone as a box round it, 48 by 32; and the Soft Zone as a larger box, 192 by 128. They are drawn on the camera, and move with it, not with him. Each corner is a handle: drag it to change the zone. The square in the circle is the Offset’s: drag it to move where he sits.

  1. Press F5, hold D for a second, and press F6 to pause. Press F5 again to stop.
The editor in Play at step 120, a second into a run east, the camera selected and looked through: the watchman running, his cape flying behind him, just left of the circle, his feet inside the small box, the boxes where they were in the picture, the street under them moved on; the Inspector’s Position reads x 231.927 and y -24.0
A second into a run: the boxes stay with the camera, and he is left of the circle. The camera is ahead of him.

While he runs, the camera is ahead of him, so he is drawn left of the circle, with more street ahead of him in the picture than behind. His feet can be inside the Dead Zone’s box while the camera moves, since the box tests his point plus the lead, and the lead, up to 80 units, is not drawn. The Camera tab’s Rig rows name the live shot:

The Camera tab in Play, two seconds into a run east: Playing, Game size 1280 × 720; Camera camera, At rest 408.6, -24.0, As drawn 408.6, -24.0, Node at 408.6, -24.0, Rotation 0.0°, View 320 × 180 units, Zoom 4.00 px a unit (Pixel Perfect 4 × Zoom 1.00), camera_view() left 249.0, top -114.0, right 569.0, bottom 66.0; Room: Held by No room, Clamping No, Blend None; Rig: Shot follow, Blend None
The Camera tab two seconds into a run east: Shot follow, and the camera at rest where the rig has moved its node.
The Camera tab’s Rig rows
Shot, the framing that is live, by its Name, or No rig; Blend, how far a blend into it has come, or None. Before Play the shot is the one Play opens on.

Watching it follow

Each of these is the game itself, played and recorded, at half its window’s size. Play your own with F5 or Run game.

The game: the watchman stands, takes a few quick steps east and stops, then after a moment walks on east; the west wall and the street hold still through the short steps and the pause, then slide left as he walks on
The Dead Zone. Watch the west wall: it holds still while he takes five steps and stops, and slides only when he walks on.

Five steps are 13 units, and his lead after them about 10: together still inside the box’s 24, and once he stops, the lead runs down. The camera does not move a pixel. On the sixth step of a walk, the camera starts to follow.

The game: the watchman stands, then runs east; the street scrolls with him, and as he runs he drifts from the middle of the picture to left of it
The lead. Watch where he is drawn: once he is running, the camera gets ahead of him, and he runs left of the middle with the street ahead of him in view.

After two seconds of running east, the camera rests 24.6 units ahead of his framed point. With no lead, a Time of 0, the same run leaves it 51.5 behind him: the Dead Zone’s 24 and the Damping’s lag. The lead brings it from behind him to ahead of him, by nearly all of the Limit.

The game: the watchman runs east left of the middle, turns round and runs west; for a moment he races left across the picture, then he slows on the screen, crosses the middle, and runs on right of the middle, the west wall coming into view at the end
A turn. Watch him cross the picture: the camera carries on east a moment after he turns, comes back, crosses him about 1.2 seconds after the turn, and gets ahead of him again, now to the west.

Through a run, a leap and a turn he is never further than 96 by 64 from where he is supposed to sit: the Soft Zone holds him in the picture, the turn included.

Who moves the camera

The rig, every step. It moves the camera’s node to where the framing wants it, and writes the Camera’s Zoom and Rotation from the live framing. The Camera’s own Zoom and Rotation are the rig’s now, and stay 1 and 0°. A Zoom typed on the Camera stands while you edit, which looks as if it works, and Play overwrites it on the first step. Problems says so:

The Problems tab with one warning on camera: This Camera’s Zoom (2) is overwritten every step by the Camera Rig on this node, which sets Zoom and Rotation from its framings — set them on a framing instead, or switch the rig off
A Zoom of 2 typed on the Camera, under the rig: one row in Problems.

The way to zoom with a rig is the framing’s own Zoom, which chapter 7 uses. If you tried it, set the Camera’s Zoom back to 1, and the row goes.

The rig

NodeComponentFieldValue
cameraNodePosition64, -24, his framed point
CameraOffset0, 0
Camera Rig, after the Pixel PerfectEnabledticked, as it comes
its framing followSubjectwatchman
Active, Priority, Zoom, Rotationticked, 0, 1, 0°, as they come
Duration, Ease0.50 s, EaseInOut, as they come
Dead Zone24, 16
Soft Zone96, 64
Offset0, 24
Damping0.35, 0.5
Time, Smoothing, Limit0.6, 0.6, 80

The Camera keeps chapter 2’s Letterbox and chapter 3’s Pixel Perfect. The castle still has no camera.

Check it works