Camera System

The camera system controls what portion of a cell is visible during play mode. It enables viewport framing, multi-cell scrolling, subject following with dead zones, and zoom.

Quick Reference

Want to... Where Section
Preview camera in editor Press C or View → Camera Preview Camera Preview
Change aspect ratio Camera preview label or context menu Aspect Ratio
Set initial camera position Drag camera frame in preview Initial Position
Configure dead zone Game Settings → Camera Dead Zone Dead Zone
Make object followed set X.subject true Subject Following
Pan camera by dragging Drag empty canvas area (MxN cells) Canvas Dragging
Disable manual panning set Cell.canvasDraggable false Canvas Dragging

Coordinate System

The camera operates in the unified coordinate system:

Viewport Size

The viewport size in coordinate units is:

viewportWidth  = aspectRatio / zoom
viewportHeight = 1 / zoom

Examples at zoom=1:

Aspect Ratio Viewport Size
16:9 (1.78) 1.78 × 1.00
4:3 (1.33) 1.33 × 1.00
1:1 1.00 × 1.00

Examples at zoom=2 (200%):

Aspect Ratio Viewport Size
16:9 0.89 × 0.50
1:1 0.50 × 0.50

Camera Preview

Toggle camera preview in build mode:

When preview is visible:

Grid Snapping (Shift+Drag)

In multi-cell (N×M) cells, hold Shift while resizing to snap the viewport to cell boundaries:


Aspect Ratio

Camera aspect ratio defines the viewport shape. Default is 1:1 (square).

Available presets:

Preset Ratio Use Case
21:9 2.33 Ultrawide cinema
16:9 1.78 Standard widescreen
3:2 1.50 Classic photo
4:3 1.33 Traditional TV
1:1 1.00 Square (default)
3:4 0.75 Portrait
2:3 0.67 Tall portrait
9:16 0.56 Mobile vertical
9:21 0.43 Tall mobile

Set via:


Initial Position

Each cell stores its own initial camera position (X, Y, and zoom level). Set by dragging the camera frame in preview mode. When play mode starts, the camera initializes to this position.

For 1×1 cells, initial position is typically (0.5, 0.5) - centered on the cell.

For larger cells (N×M), position the camera to show the desired starting area.


Subject Following

Objects with subject: true are tracked by the camera. The camera adjusts to keep subjects visible.

Designating Subjects

set Player.subject true    # Camera follows this object
set Player.subject false   # Stop following

Multiple subjects: Camera tracks the centroid of all subjects.

Camera Behavior

When subjects exist:

  1. Camera initializes centered on subject centroid
  2. Camera follows subjects as they move
  3. Dead zone controls how tightly camera tracks

Dead Zone

The dead zone is a centered region of the viewport where subjects can move freely without triggering camera movement.

Configuration

Set in Game Settings → Camera Dead Zone (0.0 to 1.0):

Value Behavior
0.0 Center-lock (camera always centered on subject)
0.4 Default (subject can move in middle 40%)
0.8 Loose follow (subject can reach near edges)
1.0 Edge-only (camera moves only when subject hits edge)

How It Works

Dead zone is always centered in the viewport:

┌─────────────────────────────┐
│         (camera moves)       │
│    ┌───────────────────┐    │
│    │   Dead Zone        │    │
│    │   (no movement)    │    │
│    └───────────────────┘    │
│         (camera moves)       │
└─────────────────────────────┘

Canvas Dragging

For cells larger than the viewport (MxN cells), users can drag empty space to manually pan the camera.

How It Works

  1. Click and drag on empty canvas area (not on any object)
  2. Camera pans with the drag movement
  3. When released, camera snaps back to center on subject (if one exists)

Configuration

Canvas dragging is enabled by default for MxN cells. Disable it per-cell via script:

set Cell.canvasDraggable false    # Disable manual panning
set Cell.canvasDraggable true     # Re-enable

Behavior Notes


Multi-Cell Scrolling

For cells larger than the viewport (N×M where N > viewport width or M > viewport height), the camera scrolls to follow subjects.

Camera Offset

The camera tracks scroll position as an offset in "viewport units":

offsetX = viewportLeft / viewportWidth
offsetY = viewportTop / viewportHeight

Where viewportLeft and viewportTop are the top-left corner coordinates of the visible area.

Bounds

Camera is clamped to cell bounds - it won't scroll past edges:


Examples

Center on Player Start

Position camera preview centered on where player spawns:

  1. Press C to show preview
  2. Drag frame to center on player object
  3. Play mode will start with this view

Zoom In on Action

For a close-up view:

  1. Drag corner handles inward to increase zoom
  2. Position frame over focal point
  3. Objects appear larger at runtime

Scrolling Platformer

For a 6×1 horizontal level:

  1. Create 6×1 cell
  2. Place subject (player) near left
  3. Camera will scroll as player moves right
  4. Set dead zone to 0.4 for comfortable tracking

Tall Dungeon

For a 2×4 vertical dungeon:

  1. Create 2×4 cell
  2. Set aspect ratio to 9:16 (mobile portrait)
  3. Camera scrolls vertically as subject moves