show hide actor

Try using the Set Visibility node instead:

hi, i’m trying to show and hide actor (widget) on line trace. It works, but when it’s hide i can’t show it anymore. Does anyone know how to fix it ? thanks in advance.

I’ve also tried set visibility, but it doesn’t work ((

Can you show how you toggle the visibility of the widget? The screen shot above doesn’t show the full interaction.

i’m new in UE and maybe i did something wrong. but i tried a lot of ways with visibility ((

I am a bit confused by your logic. Can you make it simpler just to make sure it works?

Make one key, say F, that spawns the Widget. One key, say G, that does Set Visibility to true and finally another key, say H, that Set Visibility to false. In this way you separate the effects of the different keys and you know it is working, then you can gradually go back to your solution.

A few comments:

  • avoid using flipflop as you don’t really know what is the first state of your variable, this can be a source of confusion
  • to keep your code/BP clean, your flipflop should only call SetVisibility(), not SpawnWidget… which is another kind of logic and should be dealt elsewhere
  • the set SetVisibility in the lower part of your screenshot is applied to a WidgetActorRef->RootComponent which is undefined for us… I presume it is created and correctly set by SpawnWidget ?
  • do you need to change the visibility of the RootComponent ? or do you to change the Visibility of the WidgetActorRef itself ?

One solution to your problem: put the SetVisibility(true) node AFTER calling the SpawnWidget (in your screenshot, you are setting the visibility to true… then spawning the widget)

More proper solution: you should Spawn the Widget elsewhere (beginplay ?) and just change the Visibility to true or false after. There is always a cost to spawn Widgets and Actors and it should be done only when necesary

yes, sorry. i did like u said, (if i understood u correctly) but it doesn t work…

yes the widget is spawned. I actually added it to actor and then spawn this actor.

yes, this is the same as my issue. So its kind of bug ? :S maybe,… can i get widget component and use set visibility for this ?

as i need to show widget when i trace some object and press trigger, then hide it with trigger again…but this actor has already there from the beginning…

I am puzzled by the way you create your widget to start with. Usually this is done with Create Widget and then Add to Viewport. Does your Widget show up at all when you press F?

Ah got it! So your Widget is actually inside an actor blueprint. Now it is clear. In fact I tracked down a similar issue that was pointed out for 4.10. Still marked as unresolved. Can you have a look if this is your case? They may be related.

I also did it, but then i couldn’t use widget interaction as my project in VR. so i could’t use controllers.

thank you, your advice is very useful. But it seems like a bug, so i cant hide/show actor with widget component…

wow , it looks like i can use it. Thank you so much

Yes, seems like a bug, but it only seems to affect widgets as components inside actors.

If you need to just show the widget on the screen, then you can use Create Widget and then Add to Viewport. In this way hiding and showing it should work.

I cannot think of any other workaround to your issue.

Apparently there are a couple of workarounds available. Check here:

Curious to know if it works for you as well. Keep me posted! :slight_smile:

I don’t think there is a bug. Here is a screenshot on how to achieve what you want on a Character Blueprint (could be done elsewhere)

In this example, the EventTick is there to perform the line trace each frame, so that when your character is in front of an ActorWidget, it selects it and keep a reference in SelectedActorWidget.

In a second step, once an ActorWidget has been selected with your LineTrace, in this example you can Toggle the ActorVisibility visibility with the F Key. It works both to show and hide the actor.

Rather than performing a LineTrace at each Tick to select the ActorWidget, you could do one LineTrace for instance when the User is triggering a key, mouse or motioncontroller button.