SetCamDofStrength
DocsSetCamDofStrength(cam, dofStrength)Description
Specifies how much the DoF effect should be applied (Set using <code>SET_CAM_NEAR_DOF</code>, <code>SET_CAM_FAR_DOF</code>, etc.)
Parameters
| Name | Type | Description |
|---|---|---|
cam | Cam | The camera handle |
dofStrength | float | Depth of Field strength (between 0.0 and 1.0) |
Quick Snippet: Scripted Cameracam
camUse this to create and control a scripted camera for this native.
-- Create a scripted camera at the player's position
local coords = GetEntityCoords(PlayerPedId())
local cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true)
SetCamCoord(cam, coords.x, coords.y, coords.z + 2.0)
SetCamRot(cam, -15.0, 0.0, GetEntityHeading(PlayerPedId()))
SetCamFov(cam, 70.0)
SetCamActive(cam, true)
RenderScriptCams(true, true, 500, true, true)
-- Restore gameplay camera:
-- RenderScriptCams(false, true, 500, true, true)
-- DestroyCam(cam, true)Returns
voidThis native does not return a value.
Examples
Official
CreateThread(function()
local camera = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true)
-- Set the cam coordinates to the player coords
local playerCoords = GetEntityCoords(PlayerPedId())
SetCamCoord(camera, playerCoords)
-- Render the camera we just created
RenderScriptCams(true)
-- Use a shallow depth of field
SetCamUseShallowDofMode(camera, true)
-- Set at what distance your camera should start to focus (Example: 0.7 meters)
SetCamNearDof(camera, 0.7)
-- Set at what distance your camera should stop focusing (Example: 1.3 meters)
SetCamFarDof(camera, 1.3)
-- Apply 100% of the DoF effect (The native you're reading documentation on)
SetCamDofStrength(camera, 1.0)
while DoesCamExist(camera) do
-- Use DoF effect (needs to be called every tick)
SetUseHiDof()
Citizen.Wait(0)
end
end)