NeoSpark314/godot_oculus_quest_toolkit

How to make HUD UI elements?

Closed this issue · 5 comments

How do I make a UI-facing label that's always facing the camera and always on-screen? I want to use it to display the number of points.

I got labels working via an OQ_UI2DLabel instance. But, it only faces one direction, and doesn't move around. I tried placing it as a child of the controller (works great in the VR simulator), camera, origin, etc. but it simply stays in place.

To be clear, I would like it to always be on-screen and facing the camera, like any other HUD element. In 2D, I could achieve this with a CanvasLayer and a label sub-control.

I figured out a hack of sorts. You can put OQ_UILabel2D nodes under the camera node, albeit you need to set a proper Z translation, like -0.5. It's ugly, but it works. Is there a better/preferred way?

I think what you describe is a good solution in VR and not ugly :-).
I can't think of a better way right now that would not be technically equivalent to the UILabel2D. And you want to have verything a real object in 3D space to have it rendered correct for both eyes.

Hmm. Maybe it's just me (new to 3D games as well as XR), but the solution is not immediately obvious; not only that you can't use a regular Label, but that it lives in 3D space instead of screen-space by default.

I don't know much about Godot's internals. It seems to me that the XR camera node you provided in the toolkit, renders to a viewport. Shouldn't it be possible to, say, add a CanvasLayer to that, and then add controls in "screen space" as usual?

The current process takes a lot of manual tweaking/iteration to get things to appear correctly (very painful to make a non-trivial HUD), not sure if it might be affected by lighting, environment, etc. nodes - which would be unexpected.

The problem with VR is that you need to render a separate image for each eye; these two images are different to keep up the illusion of a 3d scene. If this is not correct you will confuse the brain and induce sickness very quickly. So a simple 2d canvas will not work well.
But I agree that it is not easy to setup; and usally also very application specific to have a UI; most VR games and applications that I remeber did not use static huds but tried to add elements either into the world (like a menu screen that you can walk to) or make elements appear when you look at your wrist for example.

Makes sense. There's probably nothing more to do here, then. Thanks for the input.