Announcement

Collapse
No announcement yet.

destroy all actors not just one

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    destroy all actors not just one

    hello,

    i'm still very new to learning blueprint so i could be going about this all wrong -
    basically i want to stack up actors in a sort of totem. after a stack of 10 gets generated, they all get destroyed and the stacking starts over again. it's all working except for only one gets destroyed after the loop runs. so after SpawnActor I return the value to Destroy Actor but only the top actor on the stack gets destroyed. How would I destroy all of them? Am I going about this in an efficent way or am I way off base? Banging my head on the wall!! Thanks for any help!!

    Click image for larger version

Name:	destroyAll.jpg
Views:	1
Size:	237.2 KB
ID:	1154826

    #2
    What it looks like you are doing is taking the reference of the last object you created and destoying that. You need to get references to all of the actors that you want to destroy.

    I would recomend using "get all actors of class" if those are completely unique to the rest of the actors in your scene.

    If you want more control and not just nuking all of those actors in the entire scene: trying creating an array of actors and adding that recently created actor to it. When the totem is at the right length, call destroy on all the actors in the array. Doing this would also allow you to get rid of the totem height variable; you could just use the lengthof the actor aray.

    Comment


      #3
      By dragging out a pin from spawn actor, you're only getting a reference to whatever was the last actor you spawned (from the last time that part of the blueprint graph was run).

      There are a few ways you can og about destroying all the actors. If these are the only actors of this type that are in your game (you do not have multiple totems at once), simply drag out a pin from Your "Whatever Actor Array" variable, get all actors of class, run a for each loop on the outputted array and destroy each actor in the loop body.

      If you do not want to destroy all such actors in your game you could add each actor to a new, custom array of actors after each of them is spawned. Then, when you want to delete them all, run a for each loop on that array and destroy each one in the loop body, clearing the array when the loop has finished.

      Edit: Seems I got beat to it.
      Advanced Turn Based Tile Toolkit (Marketplace - Support)

      Dungeon Crawler Toolkit (Marketplace - Support)

      Discord

      Comment


        #4
        Yes! Thank you all so much! I did not know about the Get All Actors of Class! Super helpful. I did the for loop with the actor array and hooked it up to Get Actors of All Class and hooked that up to Destroy Actor. It worked! Thanks!!!!!

        Comment


          #5
          Where did you put your "get all actors from class"? I'm having a related problem, but the actor that I want to destroy is a clicked actor, and I can't destroy the touched actor, I just destroy the actors when I use a "event tick", but then it destroys whatever the poiter passes by, please help!

          Comment

          Working...
          X