camera, input, skater.read and console permissions. The functions are on the camera and input pages.
1. The package
2. Start and finish
The flight is a table: where the camera is, and which way it faces. It starts 2 m above the skater, facing the way the skater faces.reskate.camera.release() gives the view back to the game’s own camera, and reskate.input.capture(false) gives the controller back to the game. Always do both when the flight ends.
A key starts and stops it. reskate.input.bind(action, key) names an action on a key or a pad combo, and the action event says its name each time it is pressed, while the game has the input (no menu, console or text box open). The player can change the key on the Binds page.
3. Which way is which
A heading is in radians about world up: 0 faces +Z, pi/2 faces +X, and a higher heading is turned to the left. The skater’sheading and the camera’s yaw here work the same way. From the yaw and the pitch (up and down):
4. The keyboard and mouse
reskate.input.flight() returns the flight keys and the mouse, the way the game’s free camera reads them:
It returns
nil unless the plugin’s camera is the one shown, and while a menu, the console or a text box is open or the game’s window is not in front. Read it once a tick: the mouse’s movement is used up as it is read.
5. A gamepad
reskate.input.gamepad() returns the controller, or nil without one or while the game’s window is not in front. Its sticks (left_x, left_y, right_x, right_y) run from -1 to 1, with up as positive y. Its triggers (left_trigger, right_trigger) run from 0 to 1. buttons holds true or false for a, b, x, y, lb, rb, up, down, left, right, start, back, left_stick and right_stick, and playstation says whether it is a PlayStation controller.
The values come as the pad reads them: give the sticks a dead zone of your own.
6. Keep the controller from the game
While you fly with a gamepad, the game would read it too and skate.reskate.input.capture(true) keeps the controller from the game for 250 ms, so call it every tick the flight goes on. It works only while the plugin’s camera is the one shown, and returns false and why otherwise (as it does on the first tick, before the view has switched). The plugin still reads the pad with gamepad() while it is captured.
7. Set the camera each tick
reskate.camera.set(position, forward, up, fov) shows the view from position along forward. up gives its roll: the camera’s top leans towards it. It need not be exactly at right angles to forward, but it cannot point along it. fov is the vertical field of view, 10 to 150 degrees; nil or 0 keeps the camera’s own. It returns ok, why: one plugin holds the camera at a time, and another plugin holding it, or following a player with it, refuses yours.
The view stays where you last set it, so set it every tick the camera moves. To roll the camera, lean up towards the camera’s right by the roll angle:
reskate.camera.held() returns true while the plugin’s view is the one shown, or false and why not: waiting for the game’s camera, or Spectate has it. Spectate takes the camera back while it runs.
The whole plugin
When the plugin stops or unloads, the game takes back everything it held: the camera, the captured controller, its binds and a freeze. Still release them yourself as soon as the flight ends, so the player gets their camera back at once.