attachCameraToElement
Client
Attaches the camera to an element: it follows the element's position and rotation until setCameraTarget gives it back to a ped.
bool attachCameraToElement(element element, float offsetX, offsetY, offsetZ [, vec3|element lookAt = nil, float roll = 0, float fov = 70])
Parameters
| Name | Type | Description |
|---|---|---|
| element | element | The element that carries the camera. |
| offsetX, offsetY, offsetZ | float | Where the camera stands, relative to the element. 0, 0, 0 becomes 2 m above it. A vec3 also works. |
| lookAt | vec3|element | Where it looks: a point relative to the element, as a vector, or another element to follow. Without it, it looks at the element itself.default nil |
| roll | float | The sideways tilt, in degrees.default 0 |
| fov | float | The field of view in degrees. 0 or less becomes 70; 180 or more becomes 179.default 70 |
Returns
true once the camera is attached. false if the element or the target is not loaded.
If the element stops existing, the camera goes back to the player.
Example
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
attachCameraToElement(vehicle, 0, -6, 2, vec3(0, 4, 0.5))
endNoteThe point to look at must be a vector (
vec3(x, y, z)); three loose numbers are refused with a warning.