GetCameraFOV

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

getCameraFOV

AVAILABLE FROM UPDATE 0.1.3
This function is available in G1R:MP 0.1.3 and later. The contract below includes the compatibility guarantees introduced in that update.

Returns the last acknowledged camera field of view cached for this client resource.

Syntax

number|false getCameraFOV()

Parameters

This function does not accept parameters.

Returns

FOV in degrees, or false when no ready acknowledged camera state is available.

Examples

Client-side: request a fresh snapshot and read it inside the matching callback.

-- Client-side: run after the local world and player camera are ready.
local query
addEventHandler("onClientCameraCommandResult", resourceRoot,
    function(requestId, ok, phase, errorText, stateJson)
        if requestId ~= query then return end
        query = nil
        if not ok or phase ~= "state" then
            outputDebugString("Camera query failed: " .. tostring(errorText), 2)
            return
        end
        local state = getCameraState()
        if not state or not state.ready then return end
        local fov = getCameraFOV()
        if fov then outputDebugString("Camera FOV: " .. tostring(fov)) end
    end)
query = requestCameraState()
if not query then outputDebugString("Camera query was not queued", 2) end

Notes

  • Client-side resource scripts only. Equivalent PascalCase spelling: GetCameraFOV. There is no server-side version.
  • This getter reads a per-resource cache, not the engine synchronously. requestCameraState refreshes it asynchronously without taking camera ownership.
  • A validated response updates the cache before onClientCameraCommandResult is dispatched. The cache is invalidated on lifecycle/connection changes.
  • A command's immediate applied/completed snapshot can precede the next rendered camera update. Request state after another frame or short timer to observe the updated view. See Scripted camera for field meanings and timing.