accessCarCamera
Provides access to the configuration of a car’s external cameras,
which are typically cycled using the ac.CarCameraParams object used to read or modify properties such as position, direction, and field of view.
Usage Patterns
Section titled “Usage Patterns”Access the first available external camera for the targeted car.
local camera = ac.accessCarCamera(0)Description
Section titled “Description”The ac.accessCarCamera function allows scripts to dynamically alter the behavior of car-mounted cameras. This is frequently used for creating cinematic tools, custom replay angles, or adjusting the default “chase” views provided by the car’s developer.
The returned object allows scripts to modify the camera’s position and orientation relative to the car, adjust its field of view for cinematic effects, and fine-tune rendering parameters such as exposure and depth of field.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
cameraIndex | integer | Yes | The 0-based index of the car camera to access. |
Return Values
Section titled “Return Values”| Type | Description |
|---|---|
ac.CarCameraParams | An object providing access to camera properties. Returns nil if the index is invalid. |
Examples
Section titled “Examples”Retrieving the first camera and setting a wide-angle field of view.
local cam = ac.accessCarCamera(0)
if cam then -- set to a very wide 110-degree FOV cam.fov = 110endCycling through every camera available on the player’s car to log their current names.
local car = ac.getCar(0)
for i = 0, car.carCamerasCount - 1 do local cam = ac.accessCarCamera(i) if cam then ac.log("Camera " .. i .. " FOV is currently: " .. cam.fov) endend