How to make widgets in item blueprints not show through other meshes

Hello!

I’m using a sphere collision on some item blueprints to show an icon above the items you can interact with, that changes to the interact key when looking at them at a certain distance. My issue is that these widgets show through other meshes (such as walls as seen in the image below). Is there a way to prevent this?

image

you could line trace to the objects to see if its blocked by anything, or possibly simpler, get the item actor and check WasRecentlyRendered?

That’s what I use to check if they’re in range to be interacted with and I guess I could just duplicate that code and make it a longer distance but since there’s no cone line trace I’m not sure it would be the best idea? I’m not sure.

WasRecentlyRendered should be connected to an event tick if I’m not mistaken, and I believe that would mess up the performance of the game, wouldn’t it?

you could do it on a timer but even then only when the player is overlapping.