Hey everyone, I would like to position the healthbar of the enemies (is a GUI in a GO) above the heads of the enemies. I use the function “world_to_screen” from the module “Orthographc camera” for this. However, there is still an offset here and I’m not sure if it’s due to the DPI and how to solve it. Here is a screenshot with two floating healthbars that have this offset. Any ideas?
ENEMY SCRIPT:
local function send_healthbar_update(self)
local world_position = go.get_position() -- Hole die Welt-Position des Enemy
local screen_position = camera.world_to_screen(CAMERA_ID, world_position) -- Konvertiere in Bildschirmkoordinaten
-- Aktualisiere die Position der Healthbar GUI
msg.post("#healthbar", "update_healthbar_position", { position = screen_position })
end
GUI-Script:
gui.set_position(healthbar_node, message.position)
gui.set_position(healthbarBg_node, message.position)
Edit:
For a better understanding: the two healthbars in the screenshot belong to two enemies enemies that are outside the field of view