Announcement

Collapse
No announcement yet.

destorying multiple spawned actors, with delay

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

    destorying multiple spawned actors, with delay

    Click image for larger version

Name:	CreateDelayDestoryBluePrint.png
Views:	1
Size:	118.3 KB
ID:	1134323

    Basically player middle mouse buttons it creates a fire particle from blueprint, delays 5 seconds then destroys the spawned actor. That works perfectly fine if you just create one. If I create multiple ones before the delay is up. The SpawnActor sets the destroy Actor to the last one created, and then the destroy fires from the delay, leaving any spawns created during the delay alive and well, minus the last one.

    I know it's something simple but any help would be appreciated.

    #2
    The simplest way would probably be to add the destroy logic to the spawned blueprint. So, On Begin Play, Delay 5, Destroy Self. One downside is that it may not be the most efficient way depending on how many are being spawned.

    Comment


      #3
      you need learn to use arrays, you can store all spawned objets.

      Comment


        #4
        actually the better option is to use the Set life span. Basically takes an actor and sets it's life span. When the time ends the actor is destroyed. Much cleaner and doesn't add over head with array and looping through it to destroy the actors.
        Thanks for the ideas though, helped me test / try things which let me stumble upon the set life spawn option.

        Comment


          #5
          this solution is a little "Laugh now, cry later.", them you over head each frame by each spawned actor. But if you are made a game for pc and spawn few actors probably you don't cry later.

          Comment


            #6
            yeap have to make sure the player doesn't create a billion of them, but it's not too bad / much of a load, adding upwards of 200 of them, running a fire explosion effect. In my game the players resource will prevent but a limited amount being spawned, so this works really well, also don't have to allocate multiple arrays for the AI that are creating similar, can reuse the code block as well, etc so works well. There was some problems with the array and adding, to the end properly as the array either grows too large as others delete off, or i keep refilling the allocation. Also problem is if the player spawns 200 of them then there is an array of 200 sitting around, that I then have to destroy as well to free up the memory footprint from the array itself.

            Comment

            Working...
            X