Skip to content

Blend to a cutscene camera ​

Goal ​

Press C to blend to a placed camera; press B to blend back to the player. Start with the player setup from Place actors.

Files you will edit ​

  • src/game.ts

Steps ​

  1. Add these imports, shared transition options and system:

    ts
    import {
      actors,
      CameraActor,
      setViewTargetWithBlend,
      spawnActor,
      type GameContext,
      type ViewTargetTransitionParams,
    } from 'gameable';
    
    const transition: ViewTargetTransitionParams = {
      blendTime: 1.2,
      blendFunction: 'easeInOut',
      blendExp: 2,
      lockOutgoing: true,
    };
    function cutsceneControls(ctx: GameContext): void {
      if (ctx.input.pressed('KeyC')) {
        const view = actors.named('cutscene');
        if (view) setViewTargetWithBlend(ctx, 0, view, transition);
      }
      if (ctx.input.pressed('KeyB')) {
        setViewTargetWithBlend(ctx, 0, null, transition);
      }
    }
  2. Add this spawn to defineGame.init(ctx) and append cutsceneControls to systems. Keep the existing player definition: it creates the seated controller that owns the manager. The camera looks down -Z from this position.

    ts
    spawnActor(ctx, CameraActor, {
      name: 'cutscene',
      position: { x: 0, y: 3, z: 8 },
      props: { fov: 50 },
    });

    Leave activateOnStart false and autoActivateSeat at -1. Selection goes through the blend call. lockOutgoing freezes the outgoing pose; false lets it keep moving. Call on the transition event, not every tick: repeated calls restart the blend. Pass blendTime: 0 for an immediate cut.

Verify ​

Run npm run dev in the game. Press C: the eye and FOV ease to the cutscene view over 1.2 seconds. Press B: the player view returns. Press B halfway through C's blend: the return starts from the currently visible pose.

See also ​