I have some function ShowUI in blueprint which draws background dialog by getting the desired string, putting it in a bubble, displaying that bubble, then setting the bubble’s visibility back to 0 several seconds later. The delay is accomplished by running another function, HideUI, through the SetTimer node. I would like to directly pass HideUI a reference to the object it should hide, as ShowUI already knows which bubble needs to be vanished, but SetTimer has no options for passing object references, even after I add a function input to HideUI.
Is there either an option to pass an argument along with SetTimer, or a more elegant way to accomplish what I’m describing?
The bubbles are widgets, the problem is that there can be more than one bubble active at once- there are 5 scattered around the screen, and a random one is chosen every time text wants to display, so the timer doesn’t have any way of figuring out which bubble it’s supposed to vanish unless I hand it a reference when the bubble is made visible.
You could simply use the Construct event in the widget blueprint to trigger a delay node, after the delay node you insert a remove from parent node. Does that solve your problem or is there a reason why this would not work for you?
That might work- to be clear, you’re suggesting setting up a single speech bubble as a self-contained widget, instantiating a new one each time text is displayed, and using the constructor to make it destroy itself? For clarification, this is what I’m doing now- the widget has five text blocks, and every time someone speaks, a random block is chosen, set to the desired text, and set visible:
Yes I would use a seperate widget for every Text. If you want a fixed amount bubbles you could place as many as them as you want in your parent widget, set them to invisible by default and unhide them when neccessary. But note that setting a widget to visible will not call the constructor, so you would have to create a function or event inside your bubble widget which sets up the timer and call it when you set it visible. And if you like to have an unlimited amount of bubbles in random positions you could dynamically create the bubbles widgets instead of placing them by hand.