getCamera | Multi Theft Auto: Wiki Skip to content

getCamera

Client-side
Server-side
Shared

This function returns an element that corresponds to the game camera.

Note
  • Using attachElements with the camera and the main player can interfere with movement.
  • Using setElementPosition/Rotation/Matrix on the camera element will automatically clear any target set with setCameraTarget.

Syntax

element getCamera ( )

Returns

  • element: camera element

Returns an camera element that corresponds to the game camera.

Code Examples

client

This example attaches (fixes) the camera to a vehicle.

local cam = getCamera()
setElementPosition(cam, 0, 0, 0) -- Clear camera target
local myVehicle = getPedOccupiedVehicle(localPlayer)
attachElements(cam, myVehicle, 0, -4, 2, -20, 0, 0)