Camera commands
 
These are the commands which control camera entities: func_camera and func_securitycamera. Camera entities also respond to many entity commands (gameX86 source code reference: camera.cpp).

Camera commands are colored in magenta in my custom SinScript syntax coloring wordfile for UltraEdit32.


continue
 
Function
 
This makes a camera resume its displacement imparted by the previous pan, follow or orbit command. This is used after the camera was previously paused with the pause command. It is basically an "un-pause" command.

Syntax
 
$<camera_name> continue

Notes & examples
 

distance
 
Function
 
This presets the horizontal distance the camera will be from the origin of the entity it is following or orbiting. Used before a follow, orbit or start command.

Syntax
 
$<camera_name> distance <value>

Notes & examples
 
The <value> argument is in map units and the default is 128. Setting this will override the camera entity's previous 'distance' key/pair value.

Note:
The distance parameter has no effect on a camera instructed to follow or orbit a path.



fixedposition
 
Function
 
Locks a camera in its current location. Afterwards, if the camera is instructed to follow or orbit a path, it won't be able to move but it will still be able to orient itself to the angles of the path (if previously set with the normalangles, splineangles or useangles commands or left at default).

Syntax
 
$<camera_name> fixedposition

Notes & examples
 
A camera cannot orbit or follow while in fixedposition mode but it is still able to lookat or watch an entity. To make the camera able to move again, use the nofixedposition command.

Note:
A camera can still be moved with the moveto or motopos commands while in this mode. The fixedposition command has no effect if issued while the camera is following or orbiting a path or entity. It must be used before an orbit or follow command to put the camera in fixedposition mode.



fixedyaw
 
Function
 
This sets a camera in fixed yaw angle watch mode. Must be used before instructing a camera to follow an entity. When the follow command is issued, the camera will first move to its following position (set by the current distance value) and view angle (set by the current yaw offset value). When the entity starts moving, the camera will follow it while maintaining a constant distance relative to the entity and a constant angle relative to the world.

Syntax
 
$<camera_name> fixedyaw

Notes & examples
 
If no yaw offset is specified before this command, the camera will point at the camera entity's "angles" key value or the last yaw angle it was set to before the follow command was issued.

Here's a mini-tutorial on how the camera follows an entity when this command is used.
  • Make a simple room 512 x 512 wide and long by 256 units high.
  • Insert 4 info_pathnode's and place them in the corners of the room about 128 units away from the walls. Give them targetname's "node1" to "node4" starting from the one in the NorthEast corner and working your way in the clockwise direction.
  • Place a Neutral_Technician_ChemicalWorker entity in the NorthEast corner about 64 units away from the corner walls. Orient him at an angle of 270 and give him the targetname "bob".
  • Draw a 16 x 16 x 16 brush in the middle of the room and make it a func_camera entity. Give it the targetname "cam1".
Take a look at Figure 1 below to get an idea of the basic map layout.

Fig. 1
Figure 1: Top View

Now write the following script:

$bob thread init_bob
waitForPlayer
end

init_bob:
local.self ignoreall
local.self respondto use
local.self definestate use camera_follow
end

camera_follow:
cuecamera $cam1
$cam1 yaw 270
$cam1 fixedyaw
$cam1 follow local.self
wait 5
local.self walkto $node1
waitFor local.self
local.self walkto $node2
waitFor local.self
local.self walkto $node3
waitFor local.self
local.self walkto $node4
waitFor local.self
wait 1
cueplayer
end


When you walk up to the technician and use him, this will call the "camera_follow" thread. Here's a step-by-step description of the events:
  • The "cuecamera" command first switches the player's view to the camera view (don't move the player while in camera view because this will take you out of camera view).
  • The "yaw" command presets the yaw offset angle (270) the camera will be set at when instructed to follow the technician. Presently the camera is pointing at 0 degrees (default) because no "angles" key/value pair was given to it in the editor. Note that the camera doesn't move yet.
  • The "fixedyaw" command presets the follow mode of the camera when instructed to follow the technician. This will make it point at a fixed orientation of 270 degrees relative to the map (set by the previous command) at all times while following the technician. Note that the camera doesn't move yet.
  • The "follow" command moves the camera into it's following position (default distance) and orientation (270 degrees) behind the technician and the thread waits 5 seconds.
  • The technician is instructed to walk to the pathnodes and the camera follows him while maintaining a constant distance and orientation. The camera will keep pointing in the same direction at all times.
If you want, you can download the example map and script of this tutorial here. I strongly suggest you download this example map archive. It contains an example both for the fixedyaw and the relativeyaw follow modes. Run them in the game one after the other to help you visualize the difference between both follow modes.


follow
 
Function
 
Places a camera in follow mode. In this mode, the camera can either be made to follow a moving entity or a path of daisy-chained info_splinepath's. Optionally, the camera can be made to watch an entity while following another entity or a path.

Syntax
 
$<camera_name> follow $<followed_entity_name>|$<splinepath_name> $<watched_entity_name>

Notes & examples
 
This command basically has 2 possible functions:
  • Following a moving entity in the game such as an actor walking or running from one place to another or any other moving object. For an example of this, refer to the mini-tutorial and example maps in the notes of the fixedyaw and relativeyaw commands.
  • Following a path of daisy-chained info_splinepath entities. This works exactly the same way as making a func_scriptobject or func_scriptmodel entity follow a path with the followpath ScriptSlave command. You can refer to the notes of that command for more details on making a camera follow a path since all the same principles apply regarding open and closed paths.
Note:
You cannot make a camera loop a path with the follow command. To make a camera follow and loop a path, you must use the orbit command.


A few things to keep in mind. When a camera is instructed to follow an entity:
  • It will take into account the current value set by the camera entity's "distance" key (default 128) or the last distance command to set the horizontal distance of the camera from the followed object's origin.
  • It will take into account the current value set by the camera entity's "yaw" key (default 0) or the last yaw command to set the viewing angle of the camera.
  • It will take into account whether it is currently in fixedyaw mode or in relativeyaw mode (default). This will determine whether the yaw value will be relative to the map (fixedyaw) or the followed entity (relativeyaw).
  • It will ignore the current value set by the camera entity's "height" key or the last height command since this only affects cameras instructed to orbit an entity or a path.
If a camera is instructed to follow a path, it will ignore distance, height, yaw, fixedyaw and relativeyaw but it will take into account ignoreangles, normalangles, splineangles and useangles.


fov  
 
Function
 
This sets the angle of the camera's field of view. The default is the same as the player's default FOV: 90 degrees.

Syntax
 
$<camera_name> fov <angle>

Notes & examples
 

height
 
Function
 
This presets the vertical distance the camera will be above the origin of the entity it is orbiting. Using a negative value as the command argument will set a vertical distance below the origin of the entity. Used before an orbit or start command.

Syntax
 
$<camera_name> height <value>

Notes & examples
 
The <value> argument is in map units and the default is 128. Setting this will override the camera entity's previous 'height' key/pair value.

Note:
The height parameter has no effect on a camera instructed to follow or orbit a path. It also has no effect on a camera instructed to follow an entity.



ignoreangles  
 
Function
 
This presets the way a camera will orient itself when following or orbiting a path of daisy-chained info_splinepath entities: it will ignore the value of the "angles" key of each splinepath entity and follow the path while pointing at it's previously set orientation.

Syntax
 
$<camera_name> ignoreangles

Notes & examples
 
The other commands which preset the way a camera will orient itself while following a path are normalangles, splineangles and useangles.


jumpcut
 
Function
 
This is supposed to preset a camera to jump instantly from its current position to its initial following or orbiting position upon the execution of the next follow or orbit command. See notes below.

Syntax
 
$<camera_name> jumpcut

Notes & examples
 
I believe this command doesn't work at all. I included it in the docs for the sake of completeness and also in case I misunderstood its function and find out what it does later but I'm practically sure it's a bogus command.

In the mean time, if you want a camera to jump instantly from its current position to the initial entity following or orbiting position, I suggest you use the jumptime command with a 0 second argument:

$cam1 jumptime 0


jumptime
 
Function
 
This presets the time a camera will take to move from its current position to its initial following or orbiting position upon the execution of the next follow or orbit command. It also determines the time a camera will take to point at or point away from a watched entity upon the execution of the next watch or nowatch command.

Syntax
 
$<camera_name> jumptime <time>

Notes & examples
 
The default time is 2 seconds. This command should be used before a follow, orbit, watch or nowatch command.


lookat
 
Function
 
Makes a camera instantly point in the direction of an entity.

Syntax
 
$<camera_name> lookat $<entity_name>

Notes & examples
 
The camera will orient itself to look at the entity instantly and is not affected by the speed setting. Also, since this command only makes the camera turn and not move as such, it can be used while the camera is in fixedposition mode.


moveto
 
Function
 
This instantly moves a camera from its present location to the location of an entity.

Syntax
 
$<camera_name> moveto $<entity_name>

Notes & examples
 
The camera snaps instantly to the origin of the entity specified in the command argument and is not affected by the speed setting.

Note:
Do not confuse this command with the moveto ScriptSlave command. It is an entirely different command with a different function even though it has the same name and some similarities.



movetopos
 
Function
 
This instantly moves a camera from its present location to an XYZ map coordinate.

Syntax
 
$<camera_name> movetopos "<X Y Z>"

Notes & examples
 
The camera snaps instantly to the XYZ map coordinate specified in the command argument and is not affected by the speed setting. A vector variable can also be used as the command argument.


nextcamera
 
Function
 
This sets the camera's "nextcamera" key to the value of the <nextcamera_name> command argument. The <nextcamera_name> must be the targetname of another func_camera or func_securitycamera entity in the map.

Syntax
 
$<camera_name> nextcamera <nextcamera_name>

Notes & examples
 
Once the command has been issued, the player will be able to switch his view to the next camera while looking through the first one by pressing the use key.


nofixedposition
 
Function
 
This unlocks a camera previously locked with the fixedposition command.

Syntax
 
$<camera_name> nofixedposition

Notes & examples
 
This command, just like the fixedposition command, has no effect if issued while the camera is following or orbiting a path or an entity. It must be used before an orbit or follow command to cancel fixedposition mode and let the camera operate in normal mode again.


normalangles  
 
Function
 
This presets the way a camera will orient itself when following or orbiting a path of daisy-chained info_splinepath entities: it will ignore the value of the "angles" key of each splinepath entity and follow the path while pointing in the direction of its forward movement at all times.

Syntax
 
$<camera_name> normalangles

Notes & examples
 
The other commands which preset the way a camera will orient itself while following a path are ignoreangles, splineangles and useangles.


nowatch
 
Function
 
This makes a camera stop watching the entity it is following/orbiting or the entity it was specifically instructed to watch with the previous watch command.

Syntax
 
$<camera_name> nowatch

Notes & examples
 
A few things to note about cameras and the nowatch command:
  • The nowatch command only works if issued while the camera is following or orbiting a path or entity. IOW, it must be used after a follow or orbit command.
  • The time a camera will take to point away from the watched entity is determined by the value set in the last jumptime command.
  • By default, a camera will watch the entity it is following or orbiting. If the nowatch command is issued while the camera is following/orbiting the entity, the camera will stop watching that entity while following/orbiting and not watch anything in particular.
  • A camera will watch an entity while it is following or orbiting a path only if it's specifically instructed to with a watch command. Afterwards, if the nowatch command is issued while following/orbiting the path, the camera will stop watching that entity and automatically go back to its default useangles mode for pointing the camera.


orbit
 
Function
 
Places a camera in orbit mode. In this mode, the camera can either be made to orbit an entity (regardless if it's moving or not) or loop a path of daisy-chained info_splinepath's. Optionally, the camera can be made to watch an entity while orbiting another entity or a path.

Syntax
 
$<camera_name> orbit $<orbited_entity_name>|$<splinepath_name> $<watched_entity_name>

Notes & examples
 
This command basically has 2 possible functions:
  • Orbiting around an entity in the game. If the entity is moving, such as an actor walking or running from one place to another, the camera will follow the actor while orbiting around it.
  • Looping a path of daisy-chained info_splinepath entities. This works exactly the same way as making a func_scriptobject or func_scriptmodel entity follow a path with the followpath ScriptSlave command when the "loop" optional argument is used. You can refer to the notes of that command for more details on making a camera orbit a path since almost all the same principles apply regarding open and closed paths.
Note:
The only principle of script slave entities looping paths which doesn't apply to orbiting cameras is the "last node" thing. When instructed to orbit a path, the camera will go straight to the node specified in the command instead of looking for all the nodes "ahead of it" and starting on the last node of the path like scriptobjects and scriptmodels do with the followpath command.


A few things to keep in mind. When a camera is instructed to orbit an entity:
  • It will take into account the current value set by the camera entity's "distance" key (default 128) or the last distance command to set the horizontal distance of the camera from the orbited object's origin.
  • It will take into account the current value set by the camera entity's "height" key (default 128) or the last height command to set the vertical distance of the camera above the orbited object's origin.
  • It will take into account the current value set by the camera entity's "speed" key (default 1) or the last speed command to set the orbiting speed of the camera.
If a camera is instructed to orbit a path, it will ignore distance, height and speed but it will take into account ignoreangles, normalangles, splineangles and useangles. It will also modify its orbiting path if the "loop" key is set in one of the splinepath nodes of the path.

Note:
The use of the loop key is definitely not recommended since it makes the orbiting movements of the camera erratic in most cases. However, for more details on its use, refer to the notes of the info_splinepath entity in the Entities documentation.



pan
 
Function
 
This makes a camera resume panning if previously started with a start command and paused with a stoppan command. In pan mode, the camera will pan based on the values of the camera entity's "panmax", "panspeed" and "angles" keys or the values preset by the panmax, panspeed and setpanangles commands.

Syntax
 
$<camera_name> pan

Notes & examples
 
A few things to note about cameras and the pan command:
  • In order to be able to pan, the camera entity's PAN spawnflag must be set.
  • In order for a camera to pan, it must first be started. This can be done by setting the camera entity's START_ON spawnflag or by using the start command. When the camera is started, it will start panning right away (no pan command required).
  • After the camera is started and pans, the panning can be paused by the stoppan command.
  • If the camera is paused by a stoppan command, the panning can be resumed by using the pan command. That's what this command is really for: pan resume.
  • If the camera is stopped by a stop command, the panning is stopped and can only be started again by a start command.

panmax
 
Function
 
This presets a camera's maximum panning arc. Used before making a camera pan.

Syntax
 
$<camera_name> panmax <angle>

Notes & examples
 
The default angle value is 45 degrees. Setting this will override the value of the camera entity's "panmax" key.

The camera will pan equally left and right of its center orientation which is set either by the "angles" key or the setpanangles command. This means that if you set panmax to 30 for example, the camera will pan 30 degrees to the left AND 30 degrees to the right from its center and the total traverse arc will actually be 60 degrees.


panspeed
 
Function
 
This presets a camera's panning speed. Used before making a camera pan.

Syntax
 
$<camera_name> panspeed <degrees_per_second>

Notes & examples
 
The default speed value is 7 degrees/sec. Setting this will override the value of the camera entity's "panspeed" key.


pause
 
Function
 
This pauses a camera's movement imparted by a previous pan, follow or orbit command.

Syntax
 
$<camera_name> pause

Notes & examples
 
When a camera is paused, all the current distance, height, and speed settings are preserved. The pause command will not interrupt a camera's movement caused by a moveto or movetopos command. To resume a paused camera's movement, use the continue command.

Note:
Do not confuse the camera pause command with the pause Master command. It is an entirely different command with a different function even though it has the same name.



relativeyaw
 
Function
 
This sets a camera in relative yaw angle watch mode. Must be used before instructing a camera to follow an entity. When the follow command is issued, the camera will first move to its following position (set by the current distance value) and view angle (set by the current yaw offset value). When the entity starts moving, the camera will follow it while maintaining a constant distance relative to the entity and a constant angle relative to the moving entity's orientation. This is the default mode when following a moving entity.

Syntax
 
$<camera_name> relativeyaw

Notes & examples
 
If no yaw offset is specified before this command, the camera will point at the same angle than the entity it is instructed to follow by default. If a yaw offset was specified beforehand, the offset will be relative to the followed entity's angle. Note that the camera only moves into its following position and orientation when the follow command is issued.

In order to get a visual idea of how this follow mode works, use the same map as the one used for the mini-tutorial in the notes of the fixedyaw command but use this slightly modified version of the script instead:

$bob thread init_bob
waitForPlayer
end

init_bob:
local.self ignoreall
local.self respondto use
local.self definestate use camera_follow
end

camera_follow:
cuecamera $cam1
$cam1 relativeyaw
$cam1 follow local.self
wait 5
local.self walkto $node1
waitFor local.self
local.self walkto $node2
waitFor local.self
local.self walkto $node3
waitFor local.self
local.self walkto $node4
waitFor local.self
wait 1
cueplayer
end


This script is virtually identical to the one in the fixedyaw mini-tutorial. The only difference is that the "yaw" command was removed and the "fixedyaw" command was changed to "relativeyaw". The new sequence of events when you use "bob" is as follows:
  • The "relativeyaw" command presets the follow mode of the camera when instructed to follow the technician. This will make it point at an orientation relative to the entity it is instructed to follow. In this case, it will be 270 degrees because the technician is itself oriented at 270 degrees. Note that the camera doesn't move yet.
  • Here, no "yaw" command was used before the "relativeyaw" command. If this had been the case, the yaw offset value would have been relative to the technician's angle instead of relative to the map because "relativeyaw" is used instead of "fixedyaw".
  • The "follow" command moves the camera into it's following position (default distance) and orientation (270 degrees) behind the technician and the thread waits 5 seconds.
  • The technician is instructed to walk to the pathnodes and the camera follows him while maintaining a constant distance and orientation relative to the technician. The camera will constantly adjust it's position and orientation to keep pointing at the technician's back at all times.
If you want, you can download the example map and script of this tutorial here. I strongly suggest you download this example map archive. It contains an example both for the relativeyaw and the fixedyaw follow modes. Run them in the game one after the other to help you visualize the difference between both follow modes.


setoverlay
 
Function
 
This presets the overlay file to use for the camera view. Must be used before a camera is looked through. The file extension of the layout filename must be omitted in the command argument.

Syntax
 
$<camera_name> setoverlay <layout_file_name>

Notes & examples
 
An overlay file consists of a list of common layout strings.These layout strings are actually commands which produce text and graphics that will be superimposed onto the camera view.

The implicit root folder of the overlay files is the layouts folder inside the PAK file or the game's base/layouts folder. There is a high resolution and a low resolution version of each overlay file. The hi-res overlay files have an .hdh file extension and the lo-res overlay files have an .hdl file extension.

The low-res overlay files are automatically used by the game when the video resolution is set at 640 x 480 or less. The hi-res overlay files are automatically used by the game when the video resolution is set at 800 x 600 or more. This is the reason why the file extension must be omitted in the command argument.


setpanangles
 
Function
 
This presets a camera's center orientation (pitch, yaw, roll) for panning. Used before making a camera pan.

Syntax
 
$<camera_name> setpanangles "<Pitch Yaw Roll>"

Notes & examples
 
The default angles value is "0 0 0". Setting this will override the value of the camera entity's "angles" key. This orientation will be the panning center of the camera and the panning arc (set by panmax) will be relative to it. A vector variable can also be used as the command argument.

A few things to keep in mind with the setpanangles command:
  • This command presets the orientation of the camera for panning. Unlike the command, it does not orient the camera all by itself.
  • If the camera is not started yet, the camera will only orient itself when the next start command is issued.
  • If the camera is already started and currently panning (IOW, not paused by the stoppan command), the camera will orient itself right away upon the execution of the setpanangles command.
  • If the camera is already started and not currently panning (IOW, paused by the stoppan command), the camera will orient itself when panning is resumed with the next pan command.

setthread  
 
Function
 
This sets the name of the thread to call when the camera is looked through.

Syntax
 
$<camera_name> setthread <thread_name>

Notes & examples
 
Setting this will override the value of the camera entity's "thread" key.


speed
 
Function
 
This sets the displacement speed of a camera while following or orbiting a path and while orbiting an entity. Used before a follow, orbit or start command. The value is a multiplier factor that is applied to a standard speed value and not an absolute value as such.

Syntax
 
$<camera_name> speed <factor>

Notes & examples
 
The speed value is a multipler factor: 1 is normal speed, 0.5 is half the normal speed, 2 is twice the normal speed, etc. Setting this will override the camera entity's previous 'speed' key/pair value.

A camera will always follow (a path) or orbit (a path or entity) at the speed set by the last speed command. IOW, a camera will always "remember" its last speed setting until stopped by the stop command which resets it to the camera's default value. You can also reset the camera's speed to the default value by using the command:

$<camera_name> speed 1

Note:
The speed parameter has no effect on a camera instructed to move with the moveto and movetopos commands. It also has no effect on a camera instructed to follow an entity since the camera's displacement speed is set by the speed of the entity it is following.



splineangles  
 
Function
 
This presets the way a camera will orient itself when following or orbiting a path of daisy-chained info_splinepath entities: it will use the value of the "angles" key of each splinepath entity while following the path. This is the default mode of orientation for cameras instructed to follow or orbit paths.

Syntax
 
$<camera_name> splineangles

Notes & examples
 
The other commands which preset the way a camera will orient itself while following a path are ignoreangles, normalangles and useangles.

Note:
This command does exactly the same thing as the useangles command. It's useful for resetting a camera's mode of path following orientation to default after it has been previously changed with either the ignoreangles or normalangles commands.



start  
 
Function
 
This makes a camera previously set to pan, follow or orbit start its movement. This can also be used after the camera was previously stopped with the stop command. It is basically an "re-start" command.

Syntax
 
$<camera_name> start

Notes & examples
 
If no distance, height, or speed commands were issued between the time the camera was stopped with the last stop command and the start command, the camera will reset those parameters to the camera entity's default values.

A few things to note about cameras and the start command:

  • If the camera entity targets an info_splinepath entity that is part of a daisy-chained path, it will start following the path at that node when the command is issued. For more details on cameras following paths, see the notes of the follow command.
  • If the camera entity targets an info_splinepath entity that is part of a daisy-chained path and has the ORBIT spawnflag set, it will start orbiting the path at that node when the command is issued. For more details on cameras orbiting paths, see the notes of the orbit command.
  • If the camera entity targets a visible brush or model based entity, it will start following that entity when the command is issued. For more details on cameras following entities, see the notes of the follow command.
  • If the camera entity targets a visible brush or model based entity and has the ORBIT spawnflag set, it will start orbiting the entity when the command is issued. For more details on cameras orbiting entities, see the notes of the orbit command.
  • If the camera does not target any entities and its PAN spawnflag is set, it will start panning when the command is issued. For more details on panning for cameras, see the pan command.
  • If the camera does not target any entities and its PAN spawnflag is not set, the start command will have no effect.
  • If the camera does not target any entities and its PAN spawnflag is not set but was previously instructed to follow or orbit a path or entity and stopped afterwards, the start command will make it re-start following or orbiting the same path or entity.

stop
 
Function
 
This stops a camera's movement set in motion by a previous follow or orbit command. It will also stop camera from panning when previously set in motion by the start command.

Syntax
 
$<camera_name> stop

Notes & examples
 
When a camera is stopped, all the current distance, height, and speed settings are reset to their default values. The stop command will not interrupt a camera's movement caused by a moveto or movetopos command. To re-start a camera's movement, use the start command.


stoppan
 
Function
 
This will make a camera suspend or pause panning if pan was previously started with a start command.

Syntax
 
$<camera_name> stoppan

Notes & examples
 
To make a camera resume panning after having been paused with this command, use the pan command.


turnto
 
Function
 
Makes a camera instantly turn to the angles specified in the command argument.

Syntax
 
$<camera_name> turnto "<Pitch Yaw Roll>"

Notes & examples
 
The camera will orient itself to pitch, yaw and roll angles instantly and is not affected by the speed setting. A vector variable can also be used as the command argument. Also, since this command only makes the camera turn and not move as such, it can be used while the camera is in fixedposition mode.

Note:
Do not confuse this command with the turnto Actor command. It is an entirely different command with a different function even though it has the same name and some similarities.



useangles  
 
Function
 
This presets the way a camera will orient itself when following or orbiting a path of daisy-chained info_splinepath entities: it will use the value of the "angles" key of each splinepath entity while following the path. This is the default mode of orientation for cameras instructed to follow or orbit paths.

Syntax
 
$<camera_name> useangles

Notes & examples
 
The other commands which preset the way a camera will orient itself while following a path are ignoreangles, normalangles and splineangles.

Note:
This command does exactly the same thing as the splineangles command. It's useful for resetting a camera's mode of path following orientation to default after it has been previously changed with either the ignoreangles or normalangles commands.



watch
 
Function
 
This can be used to make a camera watch an entity while it is following/orbiting another entity. It can also be used to make make a camera watch an entity while it is following/orbiting a path. To make a camera stop watching an entity, use the nowatch command.

Syntax
 
$<camera_name> watch $<entity_name>

Notes & examples
 
A few things to note about cameras and the watch command:
  • The watch command only works if issued while the camera is following or orbiting a path or entity. IOW, it must be used after a follow or orbit command.
  • The time a camera will take to point at the watched entity is determined by the value set in the last jumptime command.
  • By default, a camera will watch the entity it is following or orbiting. If the watch command is used to instruct the camera to watch another entity than the one it is following/orbiting, the camera will turn to watch that other entity and keep following/orbiting the first one.
  • A camera will watch an entity while it is following or orbiting a path only if it's specifically instructed to with a watch command. Afterwards, if the nowatch command is issued while following/orbiting the path, the camera will stop watching that entity and automatically go back to its default useangles mode for pointing the camera.


yaw
 
Function
 
This presets the yaw angle offset a camera will have when instructed to follow an entity. The resulting watching angle also depends on whether relativeyaw or fixedyaw is specified. Used before a follow command.

Syntax
 
$<camera_name> yaw <angle_offset>

Notes & examples
 
The default value of <angle_offset> is 0. Setting this will override the value of the camera entity's "yaw" key.

This command is used to make the camera follow an entity from a certain angle. A given yaw offset value can produce a different result depending if the angle is relative to the world (fixedyaw) or relative to the followed entity (relativeyaw).

Here's a mini-tutorial to illustrate how this works:
  • Make a simple room 512 x 512 wide and long by 256 units high.
  • Place a Neutral_Technician_ChemicalWorker entity in the center of the room. Orient him at an angle of 270 and give him the targetname "bob".
  • Draw a 16 x 16 x 16 brush about 128 units west of the actor and make it a func_camera entity. Give it the targetname "cam1" and make sure you don't set the "angles" key (so the value remains at the default "0 0 0").
Take a look at Figure 1 below to get an idea of the basic map layout.

Fig. 1
Figure 1: Top View

Now let's see what happens if I write 2 different threads for the same map. In both threads, I used the same value for the yaw command but in the first thread, I used fixedyaw and in the second, I used relativeyaw. Figures 2 and 3 below illustrate where the camera will be positionned and in what direction it will point after the follow command is executed:

Fig. 2
Fig. 3
Figure 2: yaw + fixedyaw

Figure 3: yaw + relativeyaw

            follow_fixedyaw:
            $cam1 yaw 90
            $cam1 fixedyaw
            $cam1 follow $bob
            end


            follow_relativeyaw:
            $cam1 yaw 90
            $cam1 relativeyaw
            $cam1 follow $bob
            end


In the example of Figure 2, if "bob" is later instructed to walk to info_pathnode's which make him turn to walk to the next one, the camera will keep pointing in the same direction in relation to the world and won't turn along with "bob".

In the example of Figure 3, if "bob" is later instructed to walk to info_pathnode's which make him turn to walk to the next one, the camera will keep pointing at the actor's right flank and will turn along with him to maintain its relative angle and position.