Camera
The camera object provided by the battle model provides an interface to query and move the camera. The camera interface also provides functions to query the state of an ambush controller, should the current battle be an ambush battle.
| Loaded in Campaign |
|
| Loaded in Battle |
|
| Loaded in Frontend |
|
A handle to the camera can be created by calling the battle:camera function on the battle interface. This function returns a handle to the battle camera.
Once a handle to a camera object is obtained, functions may be called on it to query or modify its state in the following form.
Example - Specification:
<object_name>:<function_name>(<args>)
Example - Creation and Usage:
local cam = bm:camera()
cam:look_at(v(0, 0, 0)) -- calling a function on the object once created
The battle camera provides a number of functions for querying and modifying ambush controllers. Use of these function should allow for querying and control of ambush battles.
-
camera:is_ambush_controller_executing() -
Returns whether an ambush controller is currently executing. This will return
truein an ambush battle, prior to the ambushing army launching their attack.Returns:
booleanis ambush controller active
-
camera:allow_user_to_skip_ambush_intro(booleanuser can skip) -
Sets whether the player can skip the ambush intro with the ESC key. By default this is disabled, but it may be desirable to enable this in certain scripted circumstances.
Parameters:
1
booleanuser can skip
Returns:
nil
-
camera:teleport_defender_when_ambush_intro_skipped(booleanteleport defender) -
Sets whether the ambush defender is teleported to the end of their movement path when the ambush intro is skipped. By default this is disabled, but it may be desirable to enable this in certain scripted circumstances.
Parameters:
1
booleanteleport defender
Returns:
nil
-
camera:play(stringfile path, booleanloop) -
Plays a specified camera file. These are files that specify camera positions in a specific format. Only for use in specific circumstances.
Parameters:
1
stringfile path
2
booleanloop
Returns:
nil
-
camera:stop([booleanstop instantly]) -
Stops a playing camera file that was started with
camera:play.Parameters:
1
booleanoptional, default value=false
stop instantly
Returns:
nil
-
camera:is_playing() -
Returns whether a scripted camera started with
camera:playis currently playing.Returns:
booleancamera is playing
-
camera:look_at(target
battle_vector,transition time
number,starting angle
[number],linear movement
[boolean],target fov
[number]
) -
Turns the camera to face a specified
battle_vectorposition over a specified time. A starting camera bearing, a transition mode and a target field of view may optionally be specified.Parameters:
1
Look-at target position.
2
numberTransition time in seconds. Supply a negative number to have the function determine an appropriate transition time.
3
numberoptional, default value=nil
Starting angle. If no angle is specified the camera's current facing is used instead (this is recommended).
4
booleanoptional, default value=false
Linear movement style. If enabled the camera will turn with a constantly velocity. If disabled the rate of camera rotation will accelerate and then decelerate.
5
numberoptional, default value=0
Field of view at the end of the transition. If set to 0 the default field of view will be used, and if set to negative the current field of view will be kept.
Returns:
nil
-
camera:move_to(position
battle_vector,target
battle_vector,transition time
number,linear movement
[boolean],target fov
[number],use command queue
[boolean]
) -
Moves the camera to a specified position, facing a specified target, over a specified time. Both positions are supplied as
battle_vectorobjects. A starting camera bearing, a transition mode and a target field of view may optionally be specified.Parameters:
1
end position of camera after transition.
2
Look-at target of camera after transition.
3
numberTransition time in seconds. Supply a negative number to have the function determine an appropriate transition time.
4
booleanoptional, default value=false
Linear movement style. If enabled the camera will move with a constantly velocity. If disabled the camera will accelerate and then decelerate.
5
numberoptional, default value=0
Field of view at the end of the transition. If set to 0 the default field of view will be used, and if set to negative the current field of view will be kept.
6
booleanoptional, default value=true
Setting this to
falseallows the camera to start moving when the game is paused, but the camera movement will not appear in replays.Returns:
nil
-
camera:position() -
Returns the current position of the camera.
Returns:
positionbattle_vector
-
camera:target() -
Returns the current look-at target of the camera.
Returns:
targetbattle_vector
Certain aspects of camera functionality can be disabled and re-enabled using the functions in this section. All functionality is enabled by default. The functionality to enable or disable is specified as one of the following strings.
Keys:
- KEYS_HEIGHT_UP_DOWN
- KEYS_PAN_LEFT_RIGHT
- KEYS_PITCH_UP_DOWN
- KEYS_FORWARD_BACKWARDS
- KEYS_STRAFE_LEFT_RIGHT
- KEYS_FOLLOW_CAMERA
- KEYS_ZOOM_CAMERA
- KEYS_CONTEXT_CAMERA
- KEYS_ALL_FUNCTIONS
- MOUSE_HEIGHT_UP_DOWN
- MOUSE_PAN_LEFT_RIGHT
- MOUSE_PITCH_UP_DOWN
- MOUSE_FORWARD_BACKWARDS
- MOUSE_STRAFE_LEFT_RIGHT
- MOUSE_FOLLOW_CAMERA
- MOUSE_ZOOM_CAMERA
- MOUSE_CONTEXT_CAMERA
- MOUSE_ALL_FUNCTIONS
- EDGE_HEIGHT_UP_DOWN
- EDGE_PAN_LEFT_RIGHT
- EDGE_PITCH_UP_DOWN
- EDGE_FORWARD_BACKWARDS
- EDGE_STRAFE_LEFT_RIGHT
- EDGE_FOLLOW_CAMERA
- EDGE_ZOOM_CAMERA
- EDGE_CONTEXT_CAMERA
- EDGE_ALL_FUNCTIONS
- UI_HEIGHT_UP_DOWN
- UI_PAN_LEFT_RIGHT
- UI_PITCH_UP_DOWN
- UI_FORWARD_BACKWARDS
- UI_STRAFE_LEFT_RIGHT
- UI_FOLLOW_CAMERA
- UI_ZOOM_CAMERA
- UI_CONTEXT_CAMERA
- UI_ALL_FUNCTIONS
- CAMERA_ALL_FUNCTIONS
-
camera:enable_functionality(functionalitystring,enableboolean, [bypass command queueboolean]) -
Enables or disables some functionality of the camera.
Parameters:
1
Functionality to enable - see the list of valid functionality strings given above.
2
Enables the functionality. Supply
falseto disable the the functionality instead.3
optional, default value=false
Bypasses the command queue. If this is set to
truethe command is processed immediately, including when paused, but the command will not be reproduced in multiplayer or in a battle replay.Returns:
nil
-
camera:change_depth_of_field(transition duration
number,focal depth
[number],focal width
[number],blur size
[number]
) -
Changes the depth of field of the camera.
Parameters:
1
numberTransition duration in seconds.
2
numberoptional, default value=nil
Focus distance.
3
numberoptional, default value=nil
Focal length.
4
numberoptional, default value=nil
Blur size.
Returns:
nil
-
camera:fade(to blackboolean,transition durationnumber, [bypass command queueboolean]) -
Fades the camera over a supplied duration from picture to black, or from black to picture.
Parameters:
1
Fade to black. The screen will fade from picture to black if this is set to
true, and from black to picture if it's set tofalse.2
Transition duration in seconds.
3
optional, default value=false
Bypass the command queue, initiating the fade immediately.
Returns:
nil
-
camera:change_height_range(numbermin height, numbermax height) -
Changes the minimum/maximum permitted altitude of the camera above the ground. If negative values are supplied the game default values are used.
Parameters:
1
numberMinimum altitude in metres.
2
numberMaximum altitude in metres.
Returns:
nil
-
camera:enable_shake() -
Enables camera shaking.
Returns:
nil
-
camera:disable_shake() -
Disables camera shaking.
Returns:
nil
-
camera:enable_anchor_to_army() -
Enables the anchor which prevents the camera from being moved too far away from the players forces.
Returns:
nil
-
camera:disable_anchor_to_army() -
Disables the anchor which prevents the camera from being moved too far away from the players forces.
Returns:
nil