Spawn/Destroy/Spawn

ucjuak5ucjuak5 Member, PRO Posts: 3

Hi guys,

I have an issue with spawning actors. I want to spawn the same the same actor (let’s call it checkbox) 5 times in random locations but in the following order:

  1. actor spawns
  2. destroyed when collide with main actor
  3. Spawn same actor spawns to random location
  4. destroy/spawn/destroy/spawn 5 times
  5. after the fifth time skip to next screen


I have created a spawn actor that spawns my ‘checkbox’ to a random location. I have created an integer (Numberofitems) and created a rule within my spawn actor:

game.NumberofItems =/< 5

then

Spawn Checkbox

Change Attribute game.Numberofitems to (game.Numberofitems)+1


What it does is it spawns one “checkbox” in random location, but it does not respawn it after destroy. I tried to create Loop but I couldn’t make it work. I would ideally like to avoid creating a timer if possible.


It bugs me because I feel there should be a simple fix and yet I can’t make it work for the life of me. :( What am I doing wrong?

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited April 2021

    Is this code in your "Checkbox" actor?

    game.NumberofItems =/< 5

    then

    Spawn Checkbox

    Change Attribute game.Numberofitems to (game.Numberofitems)+1


    If so, once the "Checkbox" actor is Destroyed this code is destroyed too so it will never run. I usually use an offscreen actor as a game controller what would watch for and control things like this.

  • ucjuak5ucjuak5 Member, PRO Posts: 3

    No, this is in the “spawn actor”. :(

  • ucjuak5ucjuak5 Member, PRO Posts: 3

    So if I understand correctly your off screen actor is what I call the “spawn actor”. The one that spawns the ‘checkbox’ to random locations

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @ucjuak5 , yes it sounds like the same thing. :)

Sign In or Register to comment.