GetCameraRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Fixed a typo)
No edit summary
Line 5: Line 5:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local function getCameraRotation ()
local function getCameraRotation ()
     local px, py, pz, lx, ly, lz = getCameraMatrix()
     return getElementRotation(getCamera())
    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
end
</syntaxhighlight>  
</syntaxhighlight>  

Revision as of 00:27, 9 January 2018

Dialog-warning.png Warning: This function no longer exists. However, below is a function that achieves a similar result.
local function getCameraRotation ()
    return getElementRotation(getCamera())
end

See Also