Camera Tutorial
Topic · Markdown · JSON · original wiki page
Basics
A cinematic camera is what is commonly known as a "cutscene"; the player's input are dismissed and events happen during the video.
A camera is local to the computer where the script has been called; one player could see a cutscene but still get killed by another player that didn't trigger the video.
How to
The list of all camera commands can be found in the Camera command group category.
Important
The "Prepare" version of camera commands has been introduced with Armed Assault. Using this set of commands helps the engine preloading the camera's (future) field of view (see also preloadCamera).
Operation Flashpoint only features the "Set" version of camera commands; use them instead (e.g camPreparePos becomes camSetPos, camCommitPrepared becomes camCommit, etc).
Only camCommitted is common to both syntaxes.
Create the camera
private _camera = "camera" camCreate getPosATL player;
Enter the camera
_camera cameraEffect ["internal", "back"];
Select a target
Object target
_camera camPrepareTarget player; // a camera will automatically target the human target's face
Position target
_camera camPrepareTarget getPosATL player;
Place the camera
World position
_camera camPreparePos (player getRelPos [5, 0]);
Relative position
_camera camCommitPrepared 0; // required to apply the prepared target first - otherwise a long trip from [0,0,0] is to follow
_camera camPrepareRelPos [0,5,0];
Apply camera's Field of View
_camera camPrepareFOV 0.5; // standard FOV is 0.7; lesser (e.g 0.5) is zoomed in, greater (e.g 0.9) is zoomed out
Apply all the changes
Immediately or with transition
_camera camCommitPrepared 0; // 0 for immediate change, value in seconds for transition
With a loading timeout
_camera camPreload 3; // since Armed Assault - instantly moves the camera once preload or timeout is done.
// tells the game to preload the future field of view. 3 here is a timeout, 0 for infinite timeout
Check that the commit happened
camCommitted _camera; // for camCommit/camCommitPrepared usage
camPreloaded _camera; // for camPreload usage
Leave the camera
_camera cameraEffect ["terminate", "back"];
Delete the camera
camDestroy _camera;
Specific cases
- A camera of bird type (seagull or crowe) cannot be controlled via "Prepare" commands - only camSet* ones.
- A camera of bird type is always committed (camCommitted will always return true) even if it is still moving toward its destination.
Full example
| SQF Syntax | SQS Syntax |
|---|---|
|
|
Picture-in-Picture
Create Source
The Picture-in-Picture (PiP) RTT (or R2T, Render to Texture) source can be defined at the Enter the camera step; instead of
_camera cameraEffect ["internal", "back"];
use the following to create a PiP source - multiple sources can be
_camera cameraEffect ["internal", "back", "rttName"];
Configure PiP Effects
A camera effect is set using setPiPEffect as such:
"rttName" setPiPEffect [2]; // sets thermal imaging
Once all the configuration is done, the PiP texture can be accessed by referencing its name "rttName". For example:
if (!isPiPEnabled) exitWith { systemChat "PiP is not enabled in video options"; };
with uiNamespace do // or use disableSerialization
{
private _ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscPicture", -1];
_ctrl ctrlSetPosition [safeZoneW * 0.75, safeZoneY, safeZoneW * 0.25, safeZoneH * 0.25];
_ctrl ctrlSetText "#(argb,512,512,1)r2t(rttName,1.0)";
_ctrl ctrlCommit 0;
};
In order to stop the camera from "broadcasting", use
_camera cameraEffect ["terminate", "back", "rttName"]; // terminates "rttName" r2t source
_camera cameraEffect ["terminate", "back"]; // terminates all r2t source
The camera still exists until destroyed with camDestroy.