GetCamera: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 15: Line 15:


==Example==  
==Example==  
This example attaches (fixes) the camera to a vehicle
This example attaches (fixes) the camera to a vehicle.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
cam = getCamera()
local cam = getCamera()
setElementPosition( cam, 0,0,0 )  -- Clear camera target
setElementPosition( cam, 0,0,0 )  -- Clear camera target
myVehicle = getPedOccupiedVehicle(localPlayer)
local myVehicle = getPedOccupiedVehicle(localPlayer)
attachElements( cam, myVehicle, 0,-4,2, -20,0,0 )
attachElements( cam, myVehicle, 0,-4,2, -20,0,0 )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 19:21, 21 March 2015

This function returns an element that corresponds to the game camera

[[{{{image}}}|link=|]] Note: Using attachElements with the camera and the main player can interfere with movement
[[{{{image}}}|link=|]] Note: Using setElementPosition/Rotation/Matrix on the camera element will automatically clear any target set with setCameraTarget

Syntax

element getCamera ()

Returns

Returns an element that corresponds to the game camera

Example

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 )

See Also