Instant multiple spawn

AtlantenAtlanten Member, PRO Posts: 56
edited November -1 in Working with GS (Mac)
Say I want to instantly spawn 100 copies of an actor, how do I go about that?

I can only find ways to spawn one at a time. Using a timer to repeat it seems it doesn't go faster than .1 seconds.

Besides from having 100 instances of the spawn behavior, is there any other way to do this?

Thanks for any help!

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    I honestly wouldn't recommend it!

    Spawning takes up a lot of memory. In my experience, just spawning two actors every .25 seconds caused my game to chug a lot (along with a maximum of three other actors spawning every few seconds).

    I'd say, for now, that this is impossible, and that it would crash your game, certainly on an ipod Touch...

    A spawning tip from the wiki:

    "Spawning actors during gameplay is a costly operation, and can cause frames to be dropped. It is best to try to spawn new actors only when necessary for gameplay. Avoid frequent spawning, and try to reduce the total number of actors on-screen at any time."

    I'll be proven wrong by one of the GS guys in a minute I'm sure!

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • SDMGSDMG Member Posts: 280
    beside this... have you tried to spawn every 0.001 sec instead of 0.1?
  • ktfrightktfright Member Posts: 964
    dont do that... everything will go super-fast then. that for sure will crash your game.
  • SDMGSDMG Member Posts: 280
    ;) Hey you are right ;))

    spawning every 0.001 sec stops here after 20-30 instances ....
    spawning every 0.01 sec stops around 280 instances...

    hmmm ... interesting ;))

    and its way slower than it should be...
  • AtlantenAtlanten Member, PRO Posts: 56
    Yeah but it's the only thing going on in the game. The playing field is generated by spawns, so that it's different every game.

    see this test game: http://www.gamesalad.com/game/play/17397

    What I need is to have the start area already filled with blocks when the game starts, not having them pop up one by one.
  • SDMGSDMG Member Posts: 280
    hmm ... you definitly don't have to spawn 100 copies for this kind of game ;)

    well... i have a very similar game... (doodle jump we are coming ;))
    and i spawn only 15 copies at the beginning of the game to fill the screen...
    than when an actor leaves the screen at the bottom i move him to a random position over the top of the screen and let him fall down again...
  • AtlantenAtlanten Member, PRO Posts: 56
    The number of spawns wasn't really the issue, that was just a number out of the air.

    What I am wondering is how to spawn multiple actors instantly, not one at a time.

    In your game, how do you spawn the 15 copies at the start?

    Thanks!
  • SDMGSDMG Member Posts: 280
    i spawn them with a timer --- like the example above... and when the level start you sometimes can see how they were spawned... but it looks ok for me ( very dynamic ;)
  • JGary321JGary321 Member Posts: 1,246
    Trust me when I say you will not be able to spawn that many actors without the iPhone chugging to a halt. You won't be able to spawn 1/10th of that. Figure out a different way. Keep in mind spawning takes ALOT of resources.

    Here is one alternative. Think recycling. Have these actors off the visible screen & when battle starts put in a change attribute that set X to random(0,480) & Y to random(0,320). Or whatever numbers you need within the random.

    Also, if you're gonna be using the same unit, consider 'moving' it upon being destroy & 'move' it again when you need it to come back into play. This way you're not spawning alot, b/c it will severely slow down your game.

    -JGary
  • SDMGSDMG Member Posts: 280
    JGary321 ... not be able to spawn 1/10 of what?

    15 actors? or 100 actors?

    i think spawning 15 actors before the gameplay starts and nothing else is moving shoud be possible?? don't you?
  • AtlantenAtlanten Member, PRO Posts: 56
    Loading stuff off screen and then snapping it in, is a cool idea. Thanks!
  • JGary321JGary321 Member Posts: 1,246
    SDMG - I would not spawn them. I would have the set off screen that way they are preloaded with the scene. The use the move function to move them randomly like u want. Spawning really does take a lot of resources. Always try to find a way to reduce spawns. In your case preloaded and move would be a better option.

    I meant 1/10 of 100. It would probably just crashes by spawning that many. But it can easily preload em.
  • SDMGSDMG Member Posts: 280
    Hi JGary123... probably you are right... and i simply don't want to hear it because now i have to redo a part of my game ;))

    But its obvious that its better to prevent unnecessary spawning...

    ty ;)
  • quantumsheepquantumsheep Member Posts: 8,188
    Believe me, I'm with you on this one SDMG (having to redo big bits of games!).

    Part of the learning process though - any future games we make will bear all this in mind till spawns are made to eat less memory! ;)

    Cheers,

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • tekkendptekkendp Member Posts: 49
    This is interesting stuff guys. I'm working on a top/down shooter, and I'm a proper spawn junkie. Ran the app on macbook - great. Ran it on my iphone 3GS - slow down to the point that it crashed.

    So to understand the concept of recycling. One of my stages involves navigating an asteroid belt. I have 4 types of asteriods (yes that's going to be reduced to two). I want the asteroids to keep on falling from the top of screen to the bottom. So you can see how the respawning is being used.

    This is where I a little confused. If I add the asteroids off screen, at scene start send then down. When then have been hit by a bullet, don't destory them, but make then opaque and move then back to the top of the screen and send them down again. Is that what you guys are recommending?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    tekkendp: yes, definitely. when the asteroids or enemies get blown up, instead of destroying them, simply move them offscreen until you need them again.

    It's certainly easier to respawn them from a logic point of view, but it will negatively affect gameplay.

    You can make pretty much any 2D game you can think of with GameSalad, and have it run nice and fast, you're just going to have to get creative with how you approach the more complicated scenes.

    People have been dealing with the slowness/lack of memory in computers since the beginning. The iPhone is a supercomputer compared to the stuff I grew up with. Even though there have always been memory issues, there have always been great games as well. There is usually always a solution to your problem.
  • tekkendptekkendp Member Posts: 49
    @firemaplegames - thanks for the tips. You are so right. Even developers working on a beast like the PS3 have to deal with slow down, memory and other performance issues. I will always be that way.

    But as a developer that's part of the fun!!!!! ;-)
  • JohnGreenArtJohnGreenArt Member Posts: 19
    I have a question somewhat related to this thread. I understand that spawning during game play can cause a lot of slowdown, but what about actors already on screen?

    I'm working on a game that uses lots of versions of a single actor. The actor has no image, just a solid color applied within GS, and it doesn't move. It is scaled and rotated and overlaps itself countless times to make irregular walls. The play screen scrolls so most of the time only a dozen or so are visible on screen at once, but the full level has 100+ versions of that same actor. The project size is less than 500k.

    Playing it through GS I haven't experienced any slowdown, and that's also with hundreds of particles being generated on the screen. Should I expect a different result with the iPhone? I haven't upgraded since I first wanted to see if the game I'm designing could be made with the software to begin with, but if there really is that much disparity between how a game runs through the game creator and on the actual hardware then I'll probably want to redesign the game from the ground up.

    What would be the maximum number of actors a level/stage can have, specifically for an iPhone? And related to that, what would the maximum particles displayed on screen be?
  • JGary321JGary321 Member Posts: 1,246
    Unfortunately you won't be able to tell until you try. If you have 100 actors with no rules, then you probably won't see ANY slowdown. If there are a lot of rules in them then you might. It all has to do with the 'weight' of the actor.

    No idea about particles as I prefer preset animations.
Sign In or Register to comment.