Camera

Scripted camera shots. The server puts one player's camera at a point, aimed by a rotation or at a point, with a field of view, moving there over some seconds. Ending a shot returns the player's view at once, and their body and input are not affected. A loading screen ends a shot, with cameraShotEnded(player, reason), where the reason is 'worldChanged', 'unavailable' or 'lost'. Client scripts have the same three calls without the player, Camera.startShot(shot), Camera.endShot() and Camera.inShot(), which film this machine's view. A client's end stops only its own shot, and that shot ending by itself fires cameraShotEnded(reason) on the client. The newest shot from either side wins. Client scripts can also read this machine's camera with Camera.getPose() and turn a screen position into a ray with Camera.rayFromScreen().

camera.startShot()

Camera.startShot(player, shot)

Starts a shot for a player, or on the client with Camera.startShot(shot), for this machine's view. Returns false if the player is gone.

camera.endShot()

Camera.endShot(player)

Returns the player's own view.

camera.inShot()

Camera.inShot(player)

Whether the player is in a shot.

camera.setThirdPerson()

Camera.setThirdPerson(options)

Client only. Shows this machine's view through the game's third-person camera, until turned off with null. The server's ThirdPerson.setMode('disabled') still wins, and the game's screens still take over the view while open. Throws a RangeError for a value out of range, and a TypeError for options that are neither an object nor null.

camera.isThirdPerson()

Camera.isThirdPerson()

Client only. Whether Camera.setThirdPerson holds the view, from the call until turned off, even while the server's mode or a game screen keeps it away. F5 and ThirdPerson.setMode('forced') do not count.

camera.getPose()

Camera.getPose()

Client only. This machine's camera this frame: { position, forward, right, up, fov, aspectRatio }. The directions are unit vectors from the camera, including roll. `fov` is the vertical angle in degrees actually drawn, and `aspectRatio` is the window's width over height. It is the game's camera, whatever it follows, whether the player, a dialogue, a free flight or a shot. Null in the main menu and while loading.

camera.rayFromScreen()

Camera.rayFromScreen(options)

Client only. Builds { origin, direction, target } for a line from the camera through a screen position, for World.raycast. Null with no active view.