I have a widget that is not always shown but has to always work in the background, but when I use the set visibility node it stops the event tick. How do I hide the widget without stopping the widget event tick?
Regular widgets that are off screen do no tick, this is problematic especially when the widget is supposed to update its own location - it can, and often will, get stuck when sliding off-screen, for example.
You have some options but may not like any of them:
- move the script elsewhere, to a non-widget blueprint; as a general rule of thumb, the less processing the widget does, the better
- use a widget component:
This works only for world space widgets, though - afair
- use a timer instead of Tick
- have another blueprint provide the Tick update - this often makes sense as there’s a dependency of sorts between the two (or more) entities. Also it may be more performant to Tick 1 actor and send that update to others, rather than tick 100 separate actors
- if the widget is in the viewport, it needs to work but you do not want to see it - instead of making it Hidden, change its Opacity to 0
use a widget component […] have another blueprints provide the Tick update
What I also used in the past was the combination of the 2 above. An overriden widget component that Ticks and updates the regular widget it hosts. The limitation of the latter living in screen space does not apply.
Which workaround to choose is circumstantial.
Well, my widget is like a countdown you want to see only when desired. Tho I want the countdown to continue in the background even when visibility is set to hidden.
I tried setting the opacity to 0 but then I couldn’t interact with another object because for this game using the mouse cursor for interaction.
Well, my widget is like a countdown […] I want the countdown to continue in the background
So you’re using a timer already then, right? No need for Tick in the first place. You could have it run as many times per second as needed.
I tried setting the opacity to 0 but then I couldn’t interact with another object because for this game using the mouse cursor for interaction.
Set it to Not Hit-Testable (All) when you set opacity to 0. If you do not need to interact with this widget anyway, I’d set the Not Hit-Testable (All) anyway.
Countdown that does not care about Ticking or Visibility:
- the first timer is the total duration
- the second one samples the first one once per second (can be more often if you need ms)
I got it working somehow. I… well did basically what you said. I set the opacity to 0 and from the visibility node to Not Hit-Testable and when it has to appear I set the opacity to 1 and the visibility to visible. Thanks.