-- ───────────────────────────────────────────────────────────────────────────── -- Camera system -- ───────────────────────────────────────────────────────────────────────────── Camera = {} local _cam = nil --- Dolly to a point in front of the PC, looking at the screen. ---@param pcCoords vector3 ---@param pcHeading number function Camera.FocusPC(pcCoords, pcHeading) if not Config.CameraOnOpen then return end if _cam then Camera.Restore() end -- Position cam slightly behind and above the PC position (facing forward) local rad = math.rad(pcHeading) local offset = 0.6 local cx = pcCoords.x + math.sin(rad) * offset local cy = pcCoords.y - math.cos(rad) * offset local cz = pcCoords.z + 0.55 _cam = CreateCameraWithParams( "DEFAULT_SCRIPTED_CAMERA", cx, cy, cz, 0.0, 0.0, 0.0, 60.0, false, 2 ) SetCamActive(_cam, true) RenderScriptCams(true, true, 600, true, false) -- Point at screen face local tx = pcCoords.x - math.sin(rad) * 0.3 local ty = pcCoords.y + math.cos(rad) * 0.3 local tz = pcCoords.z + 0.5 PointCamAtCoord(_cam, tx, ty, tz) end --- Return to player camera. function Camera.Restore() if not _cam then return end RenderScriptCams(false, true, 500, true, false) DestroyCam(_cam, false) _cam = nil end