Please help with spawn object

If the above is not destroying an object, there’s something else set up incorrectly that we’re not seeing here.

But if you want the 2nd button remove to remove what the first buttons spawned, this will need to be different. There’s no need to copy paste all that script. Use the method I originally suggested.

Otherwise you’ll get lost in blueprint spaghetti after 5 buttons… not to mention 100 buttons.


But if i add it to one special button (named Clear) it will work for one clear, so it is problem that another button dont delete previous setup. Maybe i can do array of all BP and add to every button action that always delete all of them, do you have any idea?

Thank you for your time

Well, obviously. You’re removing some objects, not all of them. That’s why I suggested keeping it all in an array to start with.

the first aproach what u send to me, but it seems to be more complicated for me.

If you absolutely must use this method, try it like this. Each button calls a custom event and then populates the array.

  • to create a Custom Event:

image

  • give it a meaningful name, and then you can call it like so:

image

This way you can have a reusable piece of script so you do not need to copy and paste the same nodes all the time.


But if you really want a hundred buttons, a very different approach is needed. There surely is some kind of logic that decides what’s what. But again, the above should work for something quick & easy.

Good luck!

I tried a first method, its doing the same thing, so the problem must be maybe in DestroyActor and the connection i have no idea now both doing the same. I dont want to use separeted button to clear.

You do not need to… Can you show what you’ve got?

Could you clarify the way it’s supposed to work, perhaps I’m missing the end goal:

  • I have 5 buttons
  • each button spawns 3 actors
  • whichever button is pressed, old actors are destroyed and new actors take their place

is this correct? If so, it’s this:

It seems that the first approach now working well man, sorry i havent connect one of actor, u saved me lot of hours, thank you so much. You are the best

1 Like