HUD components look at mouse pointer – ShiVa Engine

HUD components look at mouse pointer

local nMouseX, nMouseY = hud.getCursorPosition ( this.getUser ( ) )
local nComponentX, nComponentY = hud.getComponentPosition ( hComponent )
local dx, dy, dz = math.vectorSubtract ( nComponentX, nComponentY, 0, nMouseX, nMouseY, 0 )
dx, dy, dz = math.vectorNormalize ( dx, dy, dz )
local angle = math.acos ( dx )
if ( math.acos ( dy ) < 90 )
then
    angle = -angle
end
hud.setComponentRotation ( hComponent, angle )



Need more answers?

  • slackBanner