OrbitCamera

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 23:50, 8 September 2026 by QCherry (talk | contribs) (Document scripted camera API and events available from G1R:MP 0.1.3)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

orbitCamera

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.

Moves the scripted camera around a fixed world-space centre while looking at that centre.

Syntax

-- Client-side
number|false orbitCamera(table center, table options)
-- Server-side
bool orbitCamera(int playerId, table center, table options)

Parameters

Name Type Required Description
playerId int yes Server-side only: the connected player whose local camera receives the command.
center table yes Required numeric x/y/z centre coordinates in metres. The centre is captured at submission and does not automatically follow a moving player.
options table yes radius=5 (0.1..50 m), height=2 (-50..50 m), startAngle=0 degrees, sweepAngle=360 (-3600..3600 degrees), durationMs, loop=false, easing="smooth".

Returns

Client-side: a positive requestId, or false when validation or queuing fails. Wait for onClientCameraCommandResult to learn the execution result. Server-side: true only means validated and queued for the connected player; false means rejected. A server return value is not a client acknowledgement.

Examples

Read the local camera/player state before issuing the command. The command's own result arrives separately in onClientCameraCommandResult.

-- 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
        orbitCamera({x=state.playerX, y=state.playerY, z=state.playerZ + 1.2},
            {radius=5, height=2, durationMs=8000, loop=true, easing="linear"})
    end)
query = requestCameraState()
if not query then outputDebugString("Camera query was not queued", 2) end

Notes

  • Available in client-side and server-side resource scripts. Equivalent PascalCase spelling: OrbitCamera.
  • Client-side options must specify durationMs from 100 to 600,000 whole milliseconds. Server-side durationMs defaults to 10,000 when omitted.
  • startAngle is finite with an absolute maximum of 360,000 degrees. A negative sweepAngle reverses direction. The complete orbit extent must remain within 100 metres of the local player.
  • The current FOV is preserved. For login backgrounds, set FOV separately; use Scripted camera for a lifecycle-safe example.
  • Client success: applied, then completed only for a non-looping orbit. A looping orbit runs until stopped, reset, interrupted or invalidated.
  • Only the owning resource may change an already controlled camera. Server and client ownership are distinct, even when resource names match; use one side consistently for a camera sequence.
  • Camera positions and complete paths/orbits must stay within 100 metres of the local character. Camera control does not move the character, change replication distance, freeze input, or enable remote-player spectating.
  • Use resetCameraPos to restore gameplay view. Resource stop, disconnect and world/character changes release camera ownership; see onClientCameraReset.
  • An applied acknowledgement confirms command handling, not that the resulting view has rendered. For a fresh read-back, request state after another frame or a short timer. See Scripted camera for lifecycle, acknowledgement and state-cache details.