How to 'remove from parent' permanently?

What I want : when a button is clicked once, it gets deleted from the game permaenently. I guess I should use savegame or game instance and I tried both , but couldn’t make it happen :frowning: (I’m a noob) help plz!

What gets deleted - a widget? Provide more info / context.

I guess I should use savegame or game instance and I tried both , but couldn’t make it happen

Show us what you’ve tried, perhaps someone can point you in the right direction. Otherwise it’s a guessing game :expressionless:

1 - I want a button inside a widget blueprint to get deleted permanently.
2 - i’ve deleted it all as it didn’t work :frowning: TBH have very little idea what to do anyway. do I have to use game instance or savegame or both perhaps??

We still do not know what you’re doing… Why wouldn’t it not be deleted? Do you restart the game, load a new level? Quit the game and return? Do you remove the widget and then create it again expecting the button to be gone?


This is what have so far:

image

Now whut?


Hmm… would this be creating the button again when I open up the widget? If so, how do I make it so that button gets deleted when I click it once?

Sorry mate, there is nothing about deletion/removal in your pic. You enable / disable a button?


If you need help, you need to explain what is going on. Every time you create a widget, it will be at its default. If you disable a button and kill the widget, then make a new one - the button will be back as it was before you disabled it.

If you’re storing this information in a Save Game - loading it would work, you could restore the widget to the state it was saved in. When you read the save game bool above, do you get correct state when you Print it?


this is the code of the button that I want to destroy when it is clicked once. But it comes to life every time I go to other map or widget.

But it comes to life every time I go to other map or widget.

That’s normal, every time you create a new widget instance, you get a brand new widget - without any changes. If we must create new widgets all the time and they need to carry the state, you’d need to store that info outside of the widget. It could be a save game but it could also be another blueprint that does not get destroyed.

As much as I would like to help you, I have no clue what you’re really attempting to do :frowning:

For example: nowhere in the above script can I see how you save the information about the button being removed…


Perhaps you could write it step by step what is supposed to happen:

  • a widget is created and added to the viewport
  • player clicks a button, the button is removed
  • the entire widget is then removed
  • we create another, identical widget
  • the previously removed button should be gone but it shows

Is this the issue? How close am I?


Do we need to destroy the widget to start with? Maybe we can simply hide it so it remembers its state? And then reuse it?

what is supposed to happen:
-a widget is created and added to the viewport
-player clicks a button inside the widget, it gives player 20 gems and the button is removed permenantly
this is all I want.

But this is just this:

I really do not understand. Do you create and add this widget to the screen again and again all the time? If so, don’t add it again.

Maybe you’re trying something like this:

?


hmmm I think the problem is actually this code. I have set different images for the button for when it is enabled/disabled. I think I probably shouldn’t start this from event construct which triggers it everytime I open the widget.?

It will trigger every time the widget is added to the viewport. Or when it’s added to a container, or re-parented. Do note that it’s common for the Construct to trigger multiple times even if it’s added once…

Perhaps closing & re-opening the widget should be done by setting Visibility - this will not trigger Construct.

And then you just manipulate the visibility:

That’s what I suggested above. This would also respect the DoOnce. If you re-create the widget every time, the DoOnce gets reset.

so I should use set visibility instead of create widget for opening and closing the widget??

Instead of creating and destroying, if you want to preserve its state, yes :slight_smile:

1 Like

If you can re-use the same widget and want it to keep its state, then yes - much better. Create it once, add to viewport, show it. Do not remove it from viewport/parent. Hide/show only instead.

It’s also more resource friendly.

1 Like

I want to set visibility as you told above instead of create widget.

We also do not know what you want to do here. Does this new Achievement widget show up after than click?


  • this maybe in the menu:

  • inside the achievement widget:

This sounds like something that would go into a generic “notification widget”? Telling the player that he gained 20 gems?

no I want the actual button that player presses to get the gem to disappear.

What is a “gem” in this context? Got any example of a game that has this, or some other sample footage?

What i'm thinking you want