Page tree
Skip to end of metadata
Go to start of metadata

Introduced in




Creates a camera which points at a specified target, and which can be moved around that target, using the movement keys (W / A / S / D).

In versions before 3.6, the action keys are hardcoded to W / A / S / D (forward / left / back / right ), Q / Z (up / down), and V (exit), but in later versions, they use any reassigned keys for the following VBS Key Actions:

  • forward: "MoveForward" , default W.
  • left: "TurnLeft", default A.
  • back: "MoveBack", default S.
  • right: "TurnRight", default D.
  • up: "SwimUp", default Q.
  • down: "SwimDown", default Z.
  • exit: "Optics", default V or Num-0.


Syntax:[target, camera, minDist, maxDist, condition, exticode] call fn_vbs_orbitCamera
  • target: Object - Target the camera should point at. Target should be stationary, as the camera becomes unstable, if the target is moving. Be aware that the camera points at the origin of the object, which might be the feet, for people.
  • camera: Object - If a camera already exists, passing it to the function prevents a new one from being created (optional, default: nil).
  • minDist: Number - Minimum distance allowed, when moving the camera (as the camera can only be moved up and down, this is normally the minimal height) (optional, default: 0.2).
  • maxDist: Number - Maximum distance allowed when moving the camera. (As the camera can only be moved up and down, this is normally the maximal height.) (optional, default: 100)
  • condition: Code - Script condition that has to be fulfilled for the camera to exit. If undefined, pressing the Optics key (normally, V) exits the function. Be aware that passing an empty code string ({}) is not the same as an undefined parameter - if condition is empty, you will not be able to exit the function. Also, the whole function is spawn-based - it returns right away to the calling script, even if any of the exit conditions are not fulfilled yet. So, if certain actions outside the function should only happen after the condition, it also has to be checked externally (optional, default: {{isKeyPressed _x} count actionKeys "Optics" > 0})
  • exitcode: Code - Script command(s) to execute when function exits. Be aware that, if you define your own exit code, the function does not destroy the camera (as that is the default exit code, which you are overriding). In that case, you would have to use the returned camera object, and destroy it manually (optional, default: {_camera cameraEffect ["TERMINATE","BACK"]; camDestroy _camera;}).
Return Value:Object - Camera used in the orbit function (either the one that is passed originally, or the one that is created later). Do not destroy the camera outside of the function, unless a custom exit code is defined. Otherwise, you will not be able to exit the function.


When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.


Orbits 'house1':
[house1] call fn_vbs_orbitCamera

Orbits 'house1', at a distance between 10-50m, and exits when the house is destroyed:
[house1,nil,10,50,{!alive house1}] call fn_vbs_orbitCameraOrbits

'civ1' until he is killed, but keeps the camera on a few seconds longer, and then destroys it outside of the function:
// Run function until 'civ1' is dead, but do not destroy the camera on exit (empty exit code)
_cam = [civ1,nil,10,10,{!alive civ1},{}] call fn_vbs_orbitCamera;
// Store the generated camera in _cam, so it can be used later
// The function is spawned, so the calling script continues right away
sleep 3; // After 3 seconds, kill 'civ1'
civ1 setDamage 1;
// Wait until the function condition is fulfilled ('civ1' is dead)
waitUntil {!alive civ1};
sleep 3; // Keep the camera on for another 3 seconds
_cam cameraEffect ["TERMINATE","BACK"]; // Then destroy it
camDestroy _cam;

Additional Information

See also: fn vbs camSetFixedShot