#Widget removing
1 messages · Page 1 of 1 (latest)
@plush kernel @rain creek I've made thread for less spam
and in the widget where it works in both scenarios it happens only once in contruct
if it happens twice in the first screen, the it means only the last added widget (cause the variable is set to the new one, and the previous delay gets updated with latest variable is removed,
also i don't use on construct myself usually because i don't 100% understand how it works, but the logic runs usuall more than once and 99% of time my logic is Initialization that should happen only 1 in a life time).
on construct runs basically every time the game thinks the widgets needs to be constructed, like if you add it to viewport, if you add to some panel etc.
if you changed OnConstruct to Initialize(custom event) then you would not have this problem
like it's stupid but this screen above runs 2 times (is it going from Button OnClicked or from OnConstruct?)
then inside it you see only 1 remove because it got refreshed and the delay runs ONCE (but 2 widgets were created)
and then you see 2 times construct cause of 2 widgets
don't take my word for it but it's like OnConstruct will run once when you create widget, and 2nd time when you add it to viewport
but in reality you wanted it to happen once:
Create Widget -> Initialize
create a custom event
call it instead of removing
thats how i do it, works every time
instead of construct
just do custom event
If it's set up like in the screenshot above, it runs once in both widgets. However, it doesn't actually remove anything, nothing happens except for the print string.
If I move it to the Event Construct of the created widget, it works as expected, but I see the "Construct" print appear twice.
What's strange is that in the second widget, where it works in both scenarios, the removal works both when using the setup from the screenshot and when using Event Construct, and the "Construct" message only prints once.
I don’t have any issue getting it to work, and your suggestions to create a custom event are totally valid. I was just asking because I’m still new to Unreal, and it really bugged me that I could copy-paste the same nodes into different widgets and get different behavior and I don’t understand why that happens.
"you see 2 times construct cause of 2 widgets" <-- i think this is true
latency is a pain in the ass
"When using a "Delay" node in Unreal Engine Blueprints, subsequent calls to the same execution path containing the "Delay" node will be ignored if the initial "Delay" is still active and counting down"
"This behavior is inherent to the "Delay" node's design, as it functions as a single-instance timer for a specific execution path. To achieve multiple, independent delays or timed events, alternative methods are required"
-google ai