Gui in game object

How can i set gui position to go position. When i add gui to go it ignore go position. As i understand gui position is separated from go, to handle different aspect ratios.
My case is simple. I have asteroids. When player click asteroid,i want to show gui right from asteroid.
Is there are some way to convert go position to screen coordinates or i need to do it myself?
I don’t want to change size or position of this gui, when aspect ratio changed.It always should be right of my asteroid. Can i do that?

Gui scenes are by default rendered in screen space and as you’ve already seen it completely ignores the position of the game object it is attached to. This can however be changed quite easily. I have an example that shows how to do this.

In the example I set the Adjust Mode of a gui scene from Per Node to Disable. I also change the material of the gui to have another predicate and use the render script to renderthe gui in the world space of your game objects.

6 Likes

Yes, i do that. But i have 2 problems.
1)I can’t draw text with custom pred. So text is ignore camera movement.(I understand.I should change font material)
2)I have button, and when camera moved,gui.pick_node() is wrong.

Can this be fixed? Or i should convert world coord to screen coords, and then change gui position?

I used to have an example with gui text nodes following game object, but I removed the example when the label component was introduced. You can still checkout the files here: https://github.com/britzl/publicexamples/commit/098de430ff2a2f9fd7cd14f87bb28ee51e7fcfd3

As for gui.pick_node you need to adjust the coordinates so that they take into account the camera offset

1 Like