How to anchor game object on screen? (SOLVED)

Hello, I’m trying to anchor compass in Top down left corner. That’s not problem, but I’m zooming in and out screen in game and I want to zoom everithing except the compass. Can anybody help me please?


I see two different options:

  1. Use a gui component instead. The component is easy to anchor in place and it is also rendered in a separate pass and not affected by the zoom of a camera.
  2. Assign the compass a different material/tag and render it in a separate pass. You need a custom render script to achieve this.
1 Like

Thank you very much, I used gui component with this code and it is working.

function update(self, dt)
local angle = math.atan2(vmath.vector3(0).y - gui.get_position(gui.get_node(“kompas”)).y, vmath.vector3(0).x - gui.get_position(gui.get_node(“kompas”)).x)
rot = vmath.quat_rotation_z(angle)
gui.set_rotation(gui.get_node(“kompas”), rot)
end

Small tip: If you put your code (in the forum post) within 3 apostophes, it will get formatted like Lua:

E.g. ``` some code ```

function update(self, dt)
    ...
end
2 Likes

Thank you

1 Like