Show/Hide a 3D Widget with Look At Function

Hi,

I would like to display a 3D Widget when I look objects and then hide it when I’m not looking it.
The 3D Widget Appears well, but doesn’t disappear.

For information: I use a blueprint interface with a Look At function to show the 3D Widget

Thanks for your Help!

What is in the “Look At” function? Without knowing how you scripted the widget to appear and disappear it will be hard to help.

Sorry, it’s a function from a bluerpint interface.

There is the function in blueprint interface

And the event function in the switch actor blueprint that calls the 3d widget

Try printing the Boolean value from the hit result and see way it’s registering when you look at and then away from the widget. If that is working then print the Boolean value just before it is used as an input in the switch actor “set visibility” and make sure those are working as expected.

I don’t know how you set up your widget but you can try to use “PropagateToChildren”.
Can you provide a screenshot of your widget?

I have tried to print the return value of the Linetrace and the result is always true. I think it’s because the wall behind the switch is already hit by the linetrace.
It should be working if the Linetrace can ignore the other objects like the wall, but I don’t know how to make that.

Line trace node has a pin “ignore”, promote it to a variable and add array elements to it for the actor types you want to ignore. So if your wall is a world static object, set it to ignore those, but make sure your widget is not a type you are then going to ignore. You might have to create a custom object channel if you don’t have the right collision settings to distinguish between your widget and the wall or other objects you want to ignore. Let me know if you need help with any of what I just explained.

Or, you can set up custom collision channels.
In project settings you can create a new collision channel like “InteractableObject”.
You can do a line trace by channel selecting the channel created.
The line trace will ignore everything else, hitting only objects that have “InteractableObject” channel set to “Block”.

Ok DjFrex, with your idea the return value from the Linetrace work fine (is true when I pointing on the switch and false when I pointing off).
But now I have another problem in the switch Blueprint. I print the Visibility Pin from the Event Lookat (Screenshot below),

but when I pointing on the switch, the visibility value go well to true but stay to true. The False value doesn’t print out !

Can anyone tell me how I can cast the FirstPersonCharacter from the switch blueprint.
Maybe If I make a boolean variable on the return value of the linetrace and I cast it from the switch blueprint this will work fine ?

Just right click in the event graph of the switch BP and say “cast to firstpersoncharacter”. Then drag off the object pin and say “get player character”. Should work fine.

Thank for all your ideas ! It’s working now, but I take another way to solve the problem.
Here is the way I take :

1°) The Switch Blueprint :

2°) the FirstPersonCharacter blueprint :

Glad it is working now!
Anyway in my opinion the “Interface” method was better.
Is a good practice try to avoid useless references and dependencies. Further if you want another object with the same behaviour, you need to add another cast in the FirstPersonCharacter blueprint. On the contrary using the interface you can leave the FirstPersonCharacter without other casts and refernces, simply implementing the interface in the new object.