GetCameraRot
Jump to navigation
Jump to search
getCameraRot
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 rotation cached for this client resource.
Syntax
table|false getCameraRot()
Parameters
This function does not accept parameters.
Returns
A table {pitch,yaw,roll} 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 rotation = getCameraRot()
if rotation then outputDebugString(("Rotation: %.2f %.2f %.2f"):format(rotation.pitch, rotation.yaw, rotation.roll)) 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:
GetCameraRot. 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.