accessMouseDelta
Returns the movement delta of the mouse in pixels since the last call. Calling this function hides the mouse cursor and fixes it in place, allowing for “endless” dragging.
Usage Patterns
Section titled “Usage Patterns”Capture movement and restore the cursor position once finished.
local delta = ac.accessMouseDelta(false, true, false)Use settings-defined raw input for camera-style movement.
local delta = ac.accessMouseDelta("camera", true, true)Description
Section titled “Description”The ac.accessMouseDelta function is essential for implementing custom first-person cameras,
3D orbit controls, or specialized mouse-steering logic.
Unlike standard mouse tracking, which stops when the cursor hits the edge of the window,
this function locks the cursor’s OS position so movement can be tracked indefinitely.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
rawInput | boolean, nil, or string | No | nil | Set to true for raw input, or "camera" to use raw input only if the user has enabled it in their settings. |
restorePosition | boolean | No | true | Whether the cursor should jump back to its starting point when released. |
force | boolean | No | false | If true, captures the mouse even if it is currently hovering over a UI window. |
Return Values
Section titled “Return Values”| Type | Description |
|---|---|
vec2 | The horizontal and vertical distance moved since the last frame. |
Examples
Section titled “Examples”Applying mouse movement to a camera orientation.
function script.update() -- only capture if the right mouse button is held if ui.mouseDown(ui.MouseButton.Right) then local delta = ac.accessMouseDelta("camera", true, true)
myCamera.yaw = myCamera.yaw + (delta.x * 0.1) myCamera.pitch = myCamera.pitch - (delta.y * 0.1) endend