Set In Actor Widget Visible or Not

I want to put a widget component inside interactive objects so it appears on screen while follow the particular object with unique text i will manualy put in each one, nice. But I want the said widgets to appear only while in contact with the Spheretrace in front of the player camera OR to disappear when not in contact with it, I can only make it visible the first time i look at it, but then it keeps on screen above the object everytime is on sight.

I just did a quick test adding a simple widget component to a blueprint. From my player, doing a linetrace and calling the event below with true or false, depending on linetrace result. The widget appears on a hit and disappears when linetrace looses focus on the object.

It looks like there must be some problem not detecting your spheretrace no longer hitting your object. For example, just using the hit actor from hit result from the trace to call the visibilty update could cause problems - but in that case, you definitely should find some “Accessed None” errors in your message log as well. At least this could explain, why you cannot switch off the visibility.

Hi - you remember I answered this yesterday :slight_smile:

I’ll give up after this…

Like I said, the typical way to do this, is in the player. You can still get specific info from the object, even when you’re making the widget in the player. This way, you don’t need any code in the object, just get the player sorted out, and you’re done :slight_smile:

But… if you really want the display to come from the object ( this would mean putting code in every object, or at least making one interactable super object and then subclassing from that for all the other objects ), you could do it like this ( I did it with text - quicker ):


You’ll notice it uses BP interfaces. That’s the only way you can call the same event on many actors, otherwise you’ll have to do lots of casting. Inside the player it’s just:

I might be missing something here, but when does it get called with false?

thanks. hm, I dont understand why mine dosnt work. Can I see the custom event being called in the player blueprint?

It’s just a line trace ( I know you said sphere, but that’s not issue here :wink: ):

What do you have?

Hi Jardy Giovan, I now found the original thread, ClockWorkOcean already answered, as he mentions below. My Code Snippet was just some test to demonstrate, that the SetVisibilty itself works fine and that there must be some logic problem. Now seeing your original question, it’s definitely the best way to go with ClockWorkOceans recommendations.