Widget remove from parent bug how to fix!?

So I’m just testing/setting up a simple currency system and I’ve run in to a problem that I don’t know how to solve. Basically when I pick up the in game currency I’m adding a widget to the screen then using delay for 3 seconds then removing from parent to get rid of the widget. This works fine, however if I pick up more currency before the timer runs out the widget stays on the screen how do I fix this?

here’s a quick video to give you a better Idea of what I’m talking about the widget is the stuff displayed in the top right hand corner of the screen keep in mind this is simply a demo project to try and learn/figure out UE4 as I’m a noob.

Just tried that node it says it’s not compatible? Thanks for the reply btw.

@moderategamer

I know, what is causing this behaviour. Basicly you create a widget in the chain everytime the overlap happens. When you don’t overlap with something in about 3 seconds, the widget will be removed. However, the problem here is, when you overlap a currency object before the delay runs out, you create and add a second widget. You end up having 2 overlayed widgets, where on gets destroyed. What you could do to solve it is either one of the following:

  1. After your overlap, create a do once node. Only reset it, when your widget is removed (aka at the end of the chain).

Hope I could be of help.

3 Likes

I’ll give that a try thought it might be something like that I did just try it with the remove all widgets node which works but unfortunately it does what it say on the tin and removes all widgets from the screen which would cause problems later down the line when I have more widgets on screen.

@moderategamer - I had this issue and solved it this way attached.

Using a variable - I set the variable to ‘yes’ when something is picked up. After the delay the variable is set back to No. A branch at the beginning (before you display the UMG) checks the condition of the variable. If it is already a Yes (meaning there is currently a message on screen), then Remove ALL widgets or another function you may want. And reset the variable again.

Awesome thankyou I tried doing something similar with a branch node and just crashed my game :stuck_out_tongue: hopefully I didn’t loose to much. I was trying to compare the stored Int in my game instance with the Int stored in my text variable of the widget or something like that can’t really remember but I think it would always come back true not sure I got the game to only display the widget once then destroy it but it wasn’t updating my the text.

I just went with a do once node then reset it when the widget is removed saves me having to create a variable but I can’t figure out how to add time to the delay for every coin I pick up because atm it just sets the timer when you pick up the first coin and runs through it then does it again if the widget has been removed and you pick up another coin. Don’t suppose you have a fix for that? or does your way already fix that?

Thanks BTW that worked great appreciate the help.

@moderategamer

If you want more of a “popup” approach, this could be of help:

What it basicly does is updating the widget along the way. It will remove the previous widget, if you walk over the next currency item, but add a new one, so the widget is kind of “refreshed”.
It will also reset the delay timer every time you run over a currency item and is run independantly, so it will be removed if you go over 3 seconds.

I have an easier solution for you.

In the widget… Make the delay and remove self from parent.

Each time the widget pops up it’ll destroy itself.

Why do this? They might overlay?

How about you up the anti on it, make the widget have an animation track. It appears sit still for .5 seconds. Then fly up off the screen.

Just a though seems more video game like to me :slight_smile:

1 Like

Wow that’s so much better thanks, quick question why is there a remove from parent in the second step of the sequence? It seems to work just fine without it is there something I’m not considering? Is it just a safety sort of thing to just make sure there’s no widget before you set the new one?

The second remove from parent is just a safety step. The editor complained about adding to the viewport multiple times, so I placed it there, just to really be sure that the previous view of the widget was removed :).

Baby steps :stuck_out_tongue: I’m brand new to UE4 just learning what I can do. but something like that would be the goal

Oh I get it now I was misunderstanding how the sequence worked thanks.