UE - Widget function ignores "Do once", why?

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.

What can I do?

Did you put the DoOnce inside the function?

1 Like

Yes

image

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.

Tick is OFF :sleepy: set to “never” then, this is a UE4 bug

Is this a bound function - like in the text box field or something like this - they execute every frame.

this is a UE4 bug

Very unlikely, can you confirm the above? Can you show / explain how this function executes?

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:

image

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:

image

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…

image

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.

Thank you very much!

this tip is going to improve my FPS, because I have lots of widgets binding text with functions, and they should only trigger once.

1 Like

More reading here: