How To Make Existing Widgets Dissappear When A New One Created

Hi, i am working on a little tank project from a course i am following. I made a chest that grants the player a random buff when gets breaked by the player. And when player receives a buff, i want it to show a little icon about the buff in the corner of the screen. So i created 3 very simple widgets for testing and created the following blueprint. It works fine when the player receives first buff of a kind but when player receives the same buff second time, the widgets are simply not existing. Also i want it to destroy the existing widget immediately when a new one is created on its spot but that feature is not working very well too.

Any help would bee very appreciated. I can provide more screenshots about the player, widgets, insides of timelines etc. I only uploaded this image cause i think it’s the only relevant part.

Thanks.

1 Like

This might be handy

image

I tried using it when deleting the existing widgets (true side of the first branch) but it didn’t change anything.

When you call “RemoveFromParent” there the widget is destroyed by the garbage collector.
Instead of removing it you should just set it’s visibility to "hidden"and it will be there next time you need it. When you take a different buff just change the picture, unhide it and play the animation from the start.

Yes it’s destroyed but shouldn’t it get recreated when event happens again? Performance is not my primary concern right now, i just want to make this work. But i still tried a different approach with this:

I tried creating all 3 widgets in the begin play and then immediately collapse them. When one of the widget events happen, the widget will be visible, go through the fading process, when opacity hits 0 widget gets hidden and opacity turns back to 1. When the event happens again the widget will be in the 1 opacity and collapsed state just like when it was when the event happened for the first time. But that didn’t change anything again.

Here is the second thing i tried. If i misunderstood what you said can you be a little more spesific how can i implement what you are suggesting i am very new to both Unreal Engine and Blueprint.

In your first variant I can see the events are fighting for the CurrentWidget variable but that is avoided in your second variant.

Can you link all your Timeniess to Play form Start instead of just Play and say if there is any change?

Also can you add some breakpoints (or PrintStrings) on the start of the events to make sure that they are entered after the first one?

Where is this BP located? In your character?

1 Like

I deleted the first one in a rage outburst sorry. But i did what you said in my second variant and it just worked completely perfect thank you :smiley: I am guessing once the timeline is used it stays its endpoint and if i need to reuse it i need to use play from start? If i am wrong can you explain why this solved my issue?

Also if the first variant will work with the timeline changes should i go back to it or is this second variant better for performance?

Yes. Exactly. The timeline stops and the end and you have to play from the start or set its current time to 0 before playing. (which is functionally the same thing)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.