Widget component 'screen space' occlusion.

Hello everyone.

I was looking into a name display system for planets in my game. I was looking into ‘widget components’, and under the ‘UI’, there is a ‘space’ setting where you can choose either World or Screen. The effect I am wanting is sort of a mix of the two. I want the text to lock to the screen and always face the player (as is done using the ‘space’ setting), however I want the text to be occluded when a planet is drawn in front of it (as is done using the ‘world’ setting). Is there a way to occlude a widget that is drawn behind another object while its UI space setting is set to ‘screen’?

6819c5db50d9c76b1c09de28d6094e305638f9d1.jpeg
Here you can see the settings I am using for my widget component.

f4090e03fc82bea8d7abb4b0ccda0390fbb23da0.jpeg
And here you can see the names of Venus and Mercury being rendered over the planet Earth.

Is there a setting within the widget component that I’m not aware of, or is this something not supported by the current widget setup and I’d have to find a work around to the problem?

Thanks in advance everyone!

I know this is an old post, but did you ever figure out how to achieve this?

I was hopping to find that answer as well :frowning:

You could do a line trace from the camera to the widget position and if it’s broken don’t render it.

That solution wouldn’t be desirable if you wanted part of the widget to still show up when an object’s widget was slightly occluded.

Does anyone know how to implement this?

Line trace to each corner of the widget and only hide it when all four line traces are broken. This is an old camera trick.

When set to World guess you could always brute force the widgets scale relative to camera if you dont mind it clipping through actors:
WidgetBruteForce
WidgetOccludedWorld

or when using Screen just turn it off when a specific component (with cast shadows set to false) has been occluded:
WidgetOccluded

1 Like