I decided last week that I was finally going to start learning Godot by migrating my old Unity spaceflight sim as a first project.
I’ve got all of the flight code implemented and working better than ever, but I’m having trouble figuring out how to accomplish what I want with the GUI.
As you can see in the video linked below (at around 55 seconds in), the UI is all drawn in 3D space:
All GUI elements are drawn in 3D space including all floating indicators, etc. There are actually multiple layers of this, for example the speed and weapon power indicators and steering indicator are anchor to the center of the screen while facing forward while other elements are parented to the cockpit console. Targeting indicators and enemy ship indicators draw in 3D space but still render on top of the cockpit.
This was fairly easy to accomplish in Unity. What is the best way to approach this in Godot?
It kind of depends on whether you want the GUI’s depth buffer to interact with the world’s depth buffer. If so, you probably just want to do it all in the main view.
If you want them separate, you can create a separate viewport with its own 3D camera, set the viewport to transparent background, and draw the GUI on that. Godot will composite those for you.
For anyone who find this thread in the future: So I tried just creating a SubViewport containing a few simple images in the main scene, and Godot will not show any of the controls in the 2D editor view, but if I create an entirely new scene with the exact same controls and embed that scene as a child of a SubViewport in the main scene, it works. (I’m probably using the wrong terms, but hopefully that makes sense).