Hi!
I have an User Widget with a TextBlock. I want to hide the text block X seconds after it has been added to the viewport.
Maybe there is an event in the User Widget triggered when it is added to the viewport.
Any idea?
Thanks!
Hi @ViaCognita ,
In the Event Graph, use the Event Construct event, which executes when the widget is constructed and added to the viewport.
Alternatively, you can use On Initialized, which only executes once per widget instance and does not run again when the widget is removed from and added back to the viewport.
Next, use Set Timer by Event and set the time in seconds you want to wait before hiding the text. In this example, the timer is set to 2 seconds.
You can also use a Delay, as both options work for this case. However, I recommend using Set Timer by Event because it gives you more control over the timer, allowing you to pause, cancel, or restart it if necessary. This makes it more flexible if you need to expand the functionality in the future.
Make sure to check Is Variable for the TextBlock in the Designer panel so you can access it in the Event Graph.
This way, the text will automatically be hidden after however many seconds you want.
Hope it helps!
From what I can see and understand, your solution is also fine and should work without any issues.
I would do it inside the widget to keep all the logic related to the text’s visibility in one place. This keeps the code more organized and makes it easier to expand or reuse it in other levels or projects without having to implement the same logic in the PlayerController again.
For example, you could also do it this way.
But in the end, it depends on how you’re more comfortable working. The good thing about game development is that there are different ways to achieve the same result, and what’s important is finding the approach that best fits your project and your way of working.