Spawning An Actor 'X' Amount of Times Based On Integer?

Ok, so maybe I am completely derping out here, but is there any way to spawn several of one actor without having to add mulitple "Spawn Actor" Behaviors? My game will eventually allow players to change how many items spawn per 1 second, so how can I make it so that by default, it spawns 4 of said actor, then in the future can be changed to a higher value?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    In your spawner actor make an attribute . . . . let's call it XXX - And let's say we want to spawn 17 actors.

    . . . . . . . . . . . . . . . . . . . .

    When XXX < 17
    
          Timer every 0 seconds
    
                Spawn actor
    
                Change XXX to XXX +1
    
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    edited January 2015

    If you are working with the Macintosh version you could use a Loop Behavior to do it. I don't think the Windows version offers that behavior yet, but I could be wrong.

    Using the Loop Behavior you could:

    Set up a Game Level Integer Attribute called Spawn, set it's default value to 4

    Create a game controller actor to act as the spawner and add a Loop Behavior set up like this:

    Loop Until Numeric Expression game.Spawn = 0.0
    
    Nest your Spawn Behavior in the loop
    
    Nest a Change Attribute in the loop that says: Change Attribute game.Spawn To: game.Spawn-1
    
  • SikkJewFroSikkJewFro Member Posts: 75

    Thanks @Socks got exactly what I was looking for!

Sign In or Register to comment.