This function changes the position and direction of the camera for a player. Note: Using this function will take the camera's focus away from the player. Focus can be returned to the player using function RestoreCamera.
SetCameraMatrix can take different lists of parameters:
- bool SetCameraMatrix( Player plr, Vector pos, Vector lookat, [ Vector rot ] )
- bool SetCameraMatrix( Player plr, float posx, float posy, float posz, float lookatx, float lookaty, float lookatz, [ float rot1, float rot2 ] )
- plr - The player to set the camera matrix for
- pos - Position of the camera as a vector
- lookat - The point where the camera will target at as a vector
- rot - Camera's rotation angles as a vector. Note that only the first two values will affect the camera rotation
- posx, posy, posz - Position of the camera as floats
- lookatx, lookaty, lookatz - The point where the camera will target at as floats
- rot1, rot2 - Camera's rotation angles as floats
This function will move the player's camera to the default spawn screen position when they type '/cam'.
- function onPlayerCommand( player, command, text )
- if ( command == "cam" )
- local v1 = Vector( 1499.57, -206.88, 55.0 );
- local v2 = Vector( 1499.57, -209.46, 55.0 );
- SetCameraMatrix( player, v1, v2 );
- return 1;
The event onPlayerCommand was used in this example. More info about it in the corresponding page.