ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getCameraMatrix

Function

getCameraMatrix

Server and clientCameraIdentical to MTA:SA

Returns the camera position, the point it looks at, the roll and the field of view.

Syntax

Server

float getCameraMatrix(player thePlayer)

Client

float getCameraMatrix()

Arguments

thePlayerplayer
The player (server only).

Returns

x, y, z, lx, ly, lz, roll, fov or false.

Example

A point 10 m in front of the player's camera.

local cx, cy, cz, lx, ly, lz = getCameraMatrix()
local dx, dy, dz = lx - cx, ly - cy, lz - cz
local len = math.sqrt(dx * dx + dy * dy + dz * dz)
local tx, ty, tz = cx + dx / len * 10, cy + dy / len * 10, cz + dz / len * 10

Notes

The server only knows a set camera. On the server the function returns the matrix set with setCameraMatrix, not the player's current camera position.

See also