GetCameraRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Visual improvement)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{Deprecated}}
{{Warning|'''This function no longer exists'''. However, below there is a function that archieves a similar result.|true}}
'''This function no longer exists.''' The following code snippet achieves a similar result:
 
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local function getCameraRotation ()
local function getCameraRotation ()

Revision as of 14:19, 25 June 2014

Dialog-warning.png Warning: This function no longer exists. However, below there is a function that archieves a similar result.
local function getCameraRotation ()
    local px, py, pz, lx, ly, lz = getCameraMatrix()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
    local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) )
    --Convert to degrees
    rotx = math.deg(rotx)
    rotz = -math.deg(rotz)	
    return rotx, 180, rotz
end

See Also