SetCameraFieldOfView: Difference between revisions
(Remove misleading/incorrect information) |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{client function}} | {{client function}} | ||
{{New feature/item|3.0151|1.5.1|7397|This function sets the field of view of the ''dynamic camera'' - this is the field of view of the ''non-fixed camera'' - yes, the camera that the user can control whilst on foot or in a vehicle. The higher the field of view angle, the more you will be able to see to your sides.}} | {{New feature/item|3.0151|1.5.1|7397|This function sets the field of view of the ''dynamic camera'' - this is the field of view of the ''non-fixed camera'' - yes, the camera that the user can control whilst on foot or in a vehicle. The higher the field of view angle, the more you will be able to see to your sides.}} | ||
{{Note| | {{Note|This function omits (but doesn't override) the user game option in '''''Settings -> Video -> FOV'''''}} | ||
{{Note|It doesn't affect the FOV for the following camera modes: 1) Player aiming 2) Vehicle front bumper camera 3) Fixed camera}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setCameraFieldOfView ( string cameraMode, float fieldOfView ) | bool setCameraFieldOfView ( string cameraMode, float fieldOfView [, bool instant = false ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||Camera.setFieldOfView||getCameraFieldOfView}} | {{OOP||Camera.setFieldOfView||getCameraFieldOfView}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
'''Note:''' after 100, some unexpected things may happen to the camera, particularly in vehicles, use carefully! | '''Note:''' after 100, some unexpected things may happen to the camera, particularly in vehicles, use carefully! | ||
*'''cameraMode:''' the camera mode to | *'''cameraMode:''' the camera mode to set the field of view of: | ||
** "player": whilst walking/running | ** "player": whilst walking/running | ||
** "vehicle": whilst in vehicle | ** "vehicle": whilst in vehicle | ||
** "vehicle_max": the max the field of view can go to when the vehicle is moving at a high speed (must be higher than "vehicle") | ** "vehicle_max": the max the field of view can go to when the vehicle is moving at a high speed (must be higher than "vehicle") | ||
*'''fieldOfView:''' The field of view angle, 0 to 179. | *'''fieldOfView:''' The field of view angle, 0 to 179. | ||
===Optional arguments=== | |||
{{OptionalArg}} | |||
{{New feature/item|3.0161|1.6.0|23300| | |||
*'''instant''': If set to ''true'', the value is applied immediately, without delay (does not work with "vehicle_max"). | |||
}} | |||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the arguments are valid, ''false'' otherwise. | Returns ''true'' if the arguments are valid, ''false'' otherwise. | ||
==Example== | ==Example== | ||
In this example, the field of view for 'player walking/running' is set to 20 | In this example, the field of view for 'player walking/running' camera is set to 20, once resource fully starts. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | local function changeCameraFovOnClientResourceStart() | ||
setCameraFieldOfView("player",20) | setCameraFieldOfView("player", 20) | ||
end | end | ||
addEventHandler("onClientResourceStart", resourceRoot, | addEventHandler("onClientResourceStart", resourceRoot, changeCameraFovOnClientResourceStart)</syntaxhighlight> | ||
==See Also== | ==See Also== |
Latest revision as of 18:27, 25 July 2025
This function sets the field of view of the dynamic camera - this is the field of view of the non-fixed camera - yes, the camera that the user can control whilst on foot or in a vehicle. The higher the field of view angle, the more you will be able to see to your sides.
Syntax
bool setCameraFieldOfView ( string cameraMode, float fieldOfView [, bool instant = false ] )
OOP Syntax Help! I don't understand this!
- Method: Camera.setFieldOfView(...)
- Counterpart: getCameraFieldOfView
Required Arguments
Note: after 100, some unexpected things may happen to the camera, particularly in vehicles, use carefully!
- cameraMode: the camera mode to set the field of view of:
- "player": whilst walking/running
- "vehicle": whilst in vehicle
- "vehicle_max": the max the field of view can go to when the vehicle is moving at a high speed (must be higher than "vehicle")
- fieldOfView: The field of view angle, 0 to 179.
Optional arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
Returns
Returns true if the arguments are valid, false otherwise.
Example
In this example, the field of view for 'player walking/running' camera is set to 20, once resource fully starts.
local function changeCameraFovOnClientResourceStart() setCameraFieldOfView("player", 20) end addEventHandler("onClientResourceStart", resourceRoot, changeCameraFovOnClientResourceStart)