Hi,
I've been trying to set up a button prompt icon that fades in over interactive objects (npc's, level exits etc). My method so far has been to add a billboard Sprite3D to each interactive object and add a viewport to the Sprite3D (as a child) with Usage: 2D switched on. I then add a TextureProgress to each viewport so that the prompt can be edited over time. So far this looks like:
Spatial (base object)
-> Viewport
-> TextureProgress
This works ok. With a bit of simple code, the button fades in when the player is near to the object and fades out when moving away. The problem is that if another (transparent) object moves in front of the prompt, the prompt is obscured by it. Ideally I'd like to render the viewports in front of everything else in the scene, including objects with transparent materials with a fixed render priority. However, there appears to be no way to get a viewport to render in front of these.
And so, the main problem: as a last resort I have added some code that constantly positions the Sprite3D at a location in 3D space between the interactive object and the camera, so that it is always physically in front of everything else. This works perfectly when I adjust the translation values for the Sprite3D before building/launching the game, but if I adjust these translation values in the editor while the game is running (or add the positioning code I mentioned earlier) the viewport disappears. Even if I move the Sprite3D a tiny amount, the viewport seems to be permanently removed/hidden, however if I do the exact same thing before running the game it displays as normal. It seems that Godot does not like these translation values adjusted in real time.
Has anyone else encountered this behavior and maybe found a workaround / alternative method?
Many thanks!