Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Spawn multiple locations based on table values

app_sauceapp_sauce Posts: 206Member, PRO

Hey, I am trying to figure out an efficient (least amount of code as possible) way to spawn my level selection screen into place. The level selection screen will have a max of 100 levels. They will be displayed in rows of 5 with 20 rows. I have all of the x and y locations in a table. I want to spawn them all at once but can't figure out a way to do this besides having 100 spawn actor behaviors. I am thinking that the Loop over table behavior might be the way to go. Does anyone have any ideas for how to accomplish this task with the loop over table behavior? Thanks

SocializeTwitter , **My Site ** **Play Loop Zen Free **iOS HERE, Google Play HERE


  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    Use the loop behavior not loop over table.

    Put a managing actor on the scene.

    Make a self attribute in the actor self.row and put the number of the first row in it.


    until row.self > number of rows you have.


    X = tablecellvalue(table,self.row,column). Y = tablecellvalue(table,self.row,column)

    Change attribute self.row to self.row+1

  • app_sauceapp_sauce Posts: 206Member, PRO

    ahh I'll try this right away. Thanks @Lost_Oasis_Games

    SocializeTwitter , **My Site ** **Play Loop Zen Free **iOS HERE, Google Play HERE

  • app_sauceapp_sauce Posts: 206Member, PRO

    @Lost_Oasis_Games I tried it and it worked. But, it was taking about 4-5 seconds to load all of the actors. I need faster spawning. So, I spawn the 1st actor in each row (5 total) and then have these actors spawn button actors with the appropriate spacing(downward). It takes a fraction of a second to spawn all 100 actors. I am trying to understand why it is so much faster doing it the later way. Is it slow to access the table info? Your code was definitely better to look at but it just takes so long to spawn from the table locations.

    SocializeTwitter , **My Site ** **Play Loop Zen Free **iOS HERE, Google Play HERE

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member
    edited November 2015

    Okay so then do this. Split the spawning into two loops. So in the first one spawn rows 1 - half. Then in the second spawn rows half - end. That should cut the time down. Keep spliting it until you get the speed you want.

    It's faster because those actors are part of the scan. As with the loop it spawns on each scan. So if you had twenty actors on the scene each spawning an actor you would spawn 20 actors on each scan compared to one.

Sign In or Register to comment.