Skip to content

Camera and Viewport

Marc Flerackers edited this page Jun 9, 2024 · 5 revisions

Camera

The camera component marks the mode as a potential camera for a viewport.

add([
  camera("camera-name")
])

This will use the node's global transform as the camera transform.

Viewport

A viewport renders what a camera sees. The center of the camera is rendered in the center of the viewport. Cameras can be switched by simply assigning a new one to the viewport.

const vp = add([
  viewport("camera-name", width, height)
])

vp.camera = "second camera"

When no viewport is defined,the viewport defaults to the kaplay screen. When a viewport is defined, no default viewport is rendered. When null is assigned as camera (the default), The default camera is used.

Clone this wiki locally