GetCameraRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{Deprecated}}
{{Warning|'''This function no longer exists'''. However, below is a function that achieves 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 CAM = getCamera()--The camera is always the same element, so use this local variable to save cpu power.
    local px, py, pz, lx, ly, lz = getCameraMatrix()
function getCameraRotation ()
    local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796
     return getElementRotation(CAM) --rx, ry, rz
    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
end
</syntaxhighlight>  
</syntaxhighlight>  
Line 17: Line 12:
==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}
[[Category:Needs_Example]]

Latest revision as of 21:05, 27 June 2018

Dialog-warning.png Warning: This function no longer exists. However, below is a function that achieves a similar result.
local CAM = getCamera()--The camera is always the same element, so use this local variable to save cpu power.
function getCameraRotation ()
    return getElementRotation(CAM) --rx, ry, rz
end

See Also