Skip to content

Tutorials · Cameras and Framing · Chapter 7

Shots

35 minutes Uses: CameraRig, emit_to, in_group, heard, set_flag, cut

By the end

  • A second framing, vista, on an empty node above the gate: off until it is called, Priority 10, Zoom 0.75, a Duration of 1.5 seconds and an Ease of Overshoot
  • An Area on the street before the gate, vista-spot, whose script tells the camera, by its group, to take the vista and to come back
  • The camera’s own script, which switches the framing with set_flag and cuts back to him with cut()
  • How a blend runs, and the rig’s Cut to live framing
On this page

Where the shot looks, and where it is called

As he comes up to the gate, the camera’s 320 units of street show the beacon on its pillar at their very edge, if at all, and never the gatehouse passage past the bars, where he goes through into the castle. A second framing on the rig can show them: a shot from further back, taken when he reaches the gate. It needs something to look at, and somewhere on the street that calls it.

  1. Select town. Press + Add node and choose Node. Rename it castle-view and set its Position to 2360, -64. It is an empty node, the point the shot looks at.
  2. Select town again, press + Add node and choose Area. Rename it vista-spot and set its Position to 2340, 0.
  3. In its Area’s Shape, set Size to 280, 64 and Offset to 0, -32: the box stands on the street, from x 2200 to 2480.
vista-spot selected and framed at 293.2%: a long yellow box with a square at each corner lies on the street’s top, from left of the beacon’s pillar to well past the gate’s barred arch, the furnace burning on the pillar above it, the town’s houses behind; the Inspector shows Position x 2340.0 and y 0.0 and the AreaComponent: Shape with Kind Rectangle, Size 280.0 and 64.0, Offset 0.0 and -32.0, Solid unticked
vista-spot: its box on the street before the gate, and on through it.

castle-view is a little west of the arch’s middle, x 2425, and not over it. The vista’s view is 427 wide, and the town’s walls let a view that wide rest no further east than x 2378.7: from over the arch, the camera would rest against that edge with no room for the overshoot below. At y -64, the view runs from y -184 to 56, and the backdrop’s low layers stand on the street’s top. The spot starts where the vista holds him whole (touching it, he is 47 units in from the view’s west edge) and ends at the gatehouse passage past the bars (the castle-door Area, which takes him into the castle), so he is still in it standing against the bars, and on through the opened gate.

A second framing

  1. Select camera. In its Node fold, type watch into the Groups box, where it reads Add group, and press Enter.
  2. In its rig’s framing follow, set Duration to 0.8 and Ease to Linear.
  3. Next to Framings, press +. A second framing appears, 2; open it with its arrow.
  4. Set its Name to vista. Click Subject and choose castle-view.
  5. Untick its Active. Set Priority to 10, Zoom to 0.75, Duration to 1.5 and Ease to Overshoot. Leave the rest as it comes: Rotation 0°, no zones and no Offset, Damping 0.25 and 0.5, Time 0, Smoothing 0.2, Limit 0.
  6. Press Ctrl+S.
The camera’s Inspector narrowed with the search box, camerarig, to its CameraRigComponent: Enabled ticked; Framings, 2 items, 1 follow closed and 2 vista open: Name vista, Subject castle-view, Active unticked, Priority 10, Zoom 0.75, Rotation 0°, Duration 1.50 s, Ease Overshoot, Dead Zone 0.0 and 0.0, Soft Zone 0.0 and 0.0, Offset 0.0 and 0.0, Damping 0.25 and 0.5, Time 0.00 s, Smoothing 0.20 s, Limit 0.00 u; and the Cut to live framing button
The second framing, vista, off until a script switches it on.
The framing’s Priority
Of the framings that are Active, the one with the highest Priority is live. vista’s 10 outranks follow’s 0, so switching vista on takes the camera, and switching it off gives the camera back to follow. follow stays active the whole time underneath.
The framing’s Zoom
What the rig writes onto the Camera’s Zoom while this framing is live: 0.75 shows a third more each way than follow’s 1. Under Pixel Perfect’s 4, the screen’s zoom is 3: a view of 426.67 by 240.
Duration and Ease
The blend into this framing: how many seconds it takes, and the shape of the move. Going to vista takes vista’s; going back takes follow’s.
The Ease’s four choices
Cut jumps, with no blend at all: chapter 8’s. Linear moves at one pace from start to end. EaseInOut starts slowly and ends slowly, as it comes. Overshoot goes a little past the mark and settles back.
Cut to live framing
The rig’s button. In Play, it puts the camera at once on the framing that is live, and drops any blend under way: what a script’s cut() does. It is for trying Priorities while the game runs: change one, press it, and see the shot it gives without waiting for the blend.

The spot speaks, the camera listens

The spot does not move the camera itself. It says a word to a group, and the camera, which is in the group watch, answers in its own script. The spot says vista as he walks in and follow as he walks out:

rgs vista_spot.rgs
/// The stretch of street before the castle gate, where the view opens onto
/// the castle. It speaks to the camera, which is in the group `watch`: it says
/// `vista` as the watchman walks in, and `follow` as he walks out.
component VistaSpot : Area {
    fn on_enter(other: NodeId) {
        // He walks in: the camera is told to take the vista.
        if in_group(other, "watchman") {
            emit_to("watch", "vista");
        }
    }

    fn on_exit(other: NodeId) {
        // He walks out, whichever way: the camera is told to come back.
        if in_group(other, "watchman") {
            emit_to("watch", "follow");
        }
    }
}

The camera hears it and switches the framing:

rgs shots.rgs
/// The camera's shots. The camera is in the group `watch`, so the vista spot
/// can speak to it; this script is what it does when it hears. The two shots
/// are framings of the Camera Rig on this node, switched by name.
component Shots {
    fn on_signal() {
        // The spot said `vista`, as the watchman walked into it: the vista
        // framing is switched on. It outranks `follow`, so the camera blends
        // to it over the vista's own Duration.
        if heard("vista") {
            set_flag("CameraRigComponent", "framings.vista.active", true);
        }
        // The spot said `follow`, as he walked out of it: the vista is
        // switched off, and the camera cuts to him instead of gliding there.
        if heard("follow") {
            set_flag("CameraRigComponent", "framings.vista.active", false);
            cut();
        }
    }
}
  1. In Assets, click Assets in the path bar, so the script is written at the project’s top, then click Create, choose New script, type vista_spot and press Enter. In the Code tab, replace everything in vista_spot.rgs with the first script above, and press Ctrl+S. Make shots.rgs the same way, with the second.
  2. Select vista-spot, press Add component and choose VistaSpot.
  3. Select camera, press Add component and choose Shots.
  4. Press Ctrl+S.
emit_to(group, signal)
Says signal to every node in the group. They hear it on the next step, in their on_signal, where heard(signal) is true for that step.
set_flag(component, field, value)
Writes a true or false onto a component on this node. framings.vista.active reaches into the rig’s list by the framing’s Name: the vista framing’s Active.
cut()
Puts the camera of the game straight onto its live framing, with no blend. It needs a Camera Rig on the camera the game is seen through.

Taking the vista, and coming back

The game: the watchman walks east past the town’s houses toward the gate and stops; the view pulls back and slides east over a second and a half, until the beacon on its pillar, the barred arch and the street past it are all in the picture with him at its left, settling with a small last drift
The vista. Watch the view glide out and east to the gate as he reaches the spot, carry on a little past its mark and settle back.

He touches the spot, and two steps later the vista is live: the spot says vista the step he touches it, the camera hears it the step after and switches the framing on, and the rig, which runs before the scripts, sees the switch the step after that. Then the blend, 1.5 seconds. It goes from where the camera was to where the vista wants it, and the Overshoot carries it 6.17 units past on x and 1.59 on y, 4 percent of the move, four fifths of the way through, while the zoom dips to 0.7415 and comes back.

The Camera tab in Play in the blend: Camera camera, At rest 2364.9, -65.5, As drawn 2364.9, -65.5, Node at 2364.9, -65.5, Rotation 0.0°, View 431.2 × 242.5 units, Zoom 2.97 px a unit (Pixel Perfect 4 × Zoom 0.74), camera_view() left 2149.1, top -187.3, right 2580.2, bottom 55.2; Room: Held by town-walls, Clamping No, Blend None; Rig: Shot vista, Blend 78%
The Camera tab in the blend, at 78%: the camera past castle-view’s 2360, and the zoom below 0.75. The overshoot.
The game at the gate through the vista: the watchman standing on the street at the left; right of him the beacon’s furnace burning on its brick pillar; beyond it the gate, a black block over a stone arch closed by iron bars with a ring on the middle one; past the gate the backdrop’s fog, a house and a lamp, and the street running on to the east wall at the right edge; the castle’s green stone wall rising over the gatehouse at the top; the town’s houses, mountains and sky behind, all smaller than before
The vista, settled: the beacon, the arch and its bars, the passage past them, and him whole.

The view is 426.67 by 240, from x 2146.67 to 2573.33 and y -184 to 56. It holds the beacon, the arch and its bars, the gatehouse passage past the bars (the castle-door Area) and his whole sprite. In Play, with the camera selected, its node is on castle-view, and the Inspector shows the Camera’s Zoom at 0.75: the rig writes it, every step.

The editor in Play at step 960, camera selected and looked through: the vista, the watchman at the left on the street, the beacon’s pillar in the middle with the camera’s cross and circle on it, labelled camera, the barred arch to its right, two thin boxes along the street’s top from left of the pillar to past the arch, the spot’s Area and the castle-door Area; the Inspector shows Groups watch, Position x 2360.0 and y -64.0, and the CameraComponent with Zoom 0.75
In Play: the camera on castle-view, and its Zoom the vista’s.
The game: the watchman stands at the left of the vista, then walks west; the moment he leaves the spot the picture jumps closer, onto him, and follows him back along the street
Walking out. Watch the moment he leaves the spot: the vista is gone at once, and the camera is on him, with no glide.

Two steps after he leaves the spot, follow is live again, and the cut() puts the camera on him with no blend. It lands on a camera already with him: every framing’s spring runs the whole time, live or not, so follow has followed him all through the vista. Without cut(), the camera would glide back over follow’s own 0.8 seconds, Linear: a long slide across the street just as he turns away.

Walk back in and the vista comes again, as often as he does. Throw the lever and walk through the opened gate: the spot reaches the gatehouse passage past the bars (the castle-door Area, which changes the scene), so the vista holds until the scene changes, and there is one cut, not two.

Who moves the camera

The rig, every step, as before, but now through two framings: follow on him and vista on castle-view. A script decides which is live, by switching the vista’s Active, and the rig blends or cuts between them. The rig owns the Camera’s Zoom and Rotation: to zoom out for a shot, set the framing’s Zoom, never the Camera’s. The town’s walls still hold the picture inside them, the vista’s view too.

The vista

NodeComponentFieldValue
castle-view, a Node under townNodePosition2360, -64
vista-spot, an Area under townNodePosition2340, 0
AreaSize, Offset280, 64; 0, -32
VistaSpotthe script
cameraNodeGroupswatch
Shotsthe script
Camera Rig, framing followDuration, Ease0.8, Linear
framing vistaSubjectcastle-view
Active, Priorityunticked, 10
Zoom, Rotation0.75, 0°
Duration, Ease1.5, Overshoot
Damping; Time, Smoothing, Limit0.25, 0.5; 0, 0.2, 0, as they come

Check it works