Skip to content

Tutorials · Crypt Knight · Chapter 6

The camera

20 minutes Uses: CameraRig, Confiner

By the end

  • A Camera Rig on the camera, with one framing, follow, that has the knight for its subject
  • A dead zone, a look-ahead and a damping, tuned so the view leads the knight and does not swing when it jumps
  • A Confiner, bounds, that holds the view inside the Gate’s 1632 by 224 world units
On this page

A camera that follows

The camera is a node, so the simplest way to follow the knight is to make it the knight’s child. That follows to the pixel, and a game camera that does feels stiff. A Camera Rig follows the way a person would film: it lets the subject move about a little before it reacts, eases after it, and looks ahead of where it is going. A rig holds one or more framings, each a shot with its own subject and settings. The Gate needs one.

  1. Select camera, press Add component, and choose CameraRigComponent. The rig goes on the camera’s own node: it moves that node, and the camera with it.
  2. Next to Framings, press the +. A framing [0] appears; open it with its arrow.
  3. Set Name to follow. Click Subject, and choose knight from the list: the node the framing follows. You can also drag knight from the Hierarchy onto it.
  4. Keep Active ticked, Priority 0, Zoom 1 and Rotation 0. Set Duration to 0 and Ease to Cut: there is no other shot to blend from.
  5. Set Dead Zone to 8 and 40, Soft Zone 0 and 0, Offset 0 and 24, and Damping 0.12 and 0.5.
  6. Under them, set Time to 0.3, Smoothing to 0.2 and Limit to 32.
  7. Press Ctrl+S.
The camera selected, its Inspector narrowed to its CameraRig: Enabled, one framing, 1 follow, with the subject knight, Active ticked, Priority 0, Zoom 1, Duration 0.00 s, Ease Cut, Dead Zone 8 and 40, Soft Zone 0 and 0, Offset 0 and 24, Damping 0.12 and 0.5, Time 0.30 s, Smoothing 0.20 s and Limit 32; the Viewport shows the knight and the camera’s gizmo
Subject
The node the framing follows. A framing with no subject holds a fixed point.
Dead Zone
How far the subject may move from where it is supposed to sit, across and down, before the camera follows, in world units: the middle of the view moved by the Offset. 8 across means the camera ignores a step or two sideways. 40 down is almost as much as a held jump rises, so a jump hardly moves the view.
Offset
Where in the frame the subject sits, from the camera’s centre. The knight’s position is its feet, so 24 down puts its feet 24 units below the middle of the view, and its body, 30 tall, about at the middle.
Damping
Seconds the camera takes to close 90% of the gap, across and down. 0.12 across is quick, and the view keeps up with a run. 0.5 down is slow, so when the knight lands on a step the view settles after it, and does not lurch.
Time, Smoothing and Limit
The look-ahead: the camera leads the knight by 0.3 seconds of its motion, but never by more than 32 units. A knight running right sits left of the middle of the view, with the road ahead showing. Smoothing is the time over which the lead itself eases in and out, so turning round does not snap the view.
Duration and Ease
How long the camera takes to get into this shot from whatever was live, and the shape of the blend. A rig starts on its only framing at once, so a cut. In chapter 13 the boss’s arena adds a second framing, and the camera blends to it.

A view that stays in the level

Left like that, the rig follows the knight to the wall and past it, into the empty space beyond the level, where there is only the blue-grey of the camera’s Background. A Confiner is a room: a rectangle the view is kept inside. A scene can hold several, and the camera is held by the one whose Bounds hold its node; the Gate is one room. Cameras covers them.

  1. Select Gate, press + Add node, and choose Camera Confiner. Rename it bounds.
  2. Set its Position to 816 and 112, the middle of the level: the level is 1632 wide and 224 tall, and the node sits at half of each.
  3. Set its Bounds to 1632 and 224. Leave Blend at 0: it is the seconds the view takes to slide into a room from another, and the Gate has no other room.
  4. Press Ctrl+S.
The bounds node selected, its Inspector narrowed to its Confiner: Bounds 1632 by 224

The rig moves the camera, and then the Confiner clamps it, in the editor’s Play and in an exported game alike. The Confiner only keeps the view in: the rig does the leading and the easing.

Check it works

The game’s window after the knight has run right, climbed the step and stopped against the tall ledge: the crimson box stands left of the middle of the view, on the step, with the tall ledge rising ahead of it and the town further along behind