Hi, I created a widget and a function, but after I tested that function with a print string, it kept writing the print string text forever… weird, like if that function had a tick, so in order to branch it, I added a “Do once” and… for some weird reason, widget functions ignore the “Do Once” node, so I also tried with “Gate” same problem, then I set tick to “never”, still doesn’t work.
That node cannot remember its state because every time the function runs, it uses a brand new node - so to speak. Either place it outside of the function or use a Boolean that can live outside of the function’s scope.
A better question here is: Must we run this on Tick? Perhaps there’s a better way - an event driven one.
I just created a widget, and I added a simple text to the designer, then I wanted this text to come from the inputs, and that was it, I did not do anything fancy:
to test it I added a print string and that’s when I got the infinite text
As above, these bound functions execute every frame. It’s normal. Gate it with a boolean if you must. But why do this if you want to update something only once…
Essentially:
This way you get to choose when to update the text, it happens only once rather than 60 times per second for the rest of the game.
I think I did not understand the nature of this widget functions until now, I thought it was common practice to use functions for this, since the text has a “bind” button and it actually creates the function for you…
You can bind a function or a plain variable (or a struct component) but the polling is done every frame. It’s cool if you have a progress bar and you must update it every frame because it moves or a timer because you want to observe milliseconds fly.
But for things that are more static and do not require frequent updates, it’s more reasonable to update it manually when it’s needed. See custom event above.