HUD over 3D object – ShiVa Engine

HUD over 3D object

useful for displaying player stats etc.

local hComponent = hud.getComponent ( application.getCurrentUser ( ), "TheTemplate.TheComponent" )
--The scene 3D coordinates of the object
local sceneX, sceneY, sceneZ = object.getTranslation ( hObject, object.kGlobalSpace )
--Screen coordinates (-1,1)
local hudX, hudY = camera.projectPoint ( hCamera, sceneX, sceneY, sceneZ )
--Convert to HUD coordinates (0,100)
hudX = hudX * 50 + 50
hudY = hudY * 50 + 50
--Place the component
hud.setComponentPosition ( hComponent, hudX, hudY )



Need more answers?

  • slackBanner