Trouble spawning 50 actors at once

MammothMammoth Member Posts: 640
edited November -1 in Working with GS (Mac)
I would like to spawn 50 actors to the a random location at the bigging of the level. Here is what I have done

Rule - if number of actors is < 50

Timer - 0.001 seconds
Spawn actor
Location = random.

The problem is that they do not all spawn at once. They take time.

Has anybody done this before. I have searched the forums but I didn't really find anything like this.

Thanks in advance :)

Comments

  • AppsRacKAppsRacK Member Posts: 346
    TIMER set to 0.001 while spawning 50 actor is a bad idea. Why not just place them on the scene and move them after the scene is loaded.
  • MammothMammoth Member Posts: 640
    It doesn't crash or anything It just dons't work properly ;)
  • cbtcbt Member Posts: 644
    It is like saying "Trouble shooting bolts of lightning from my arse". It's just not possible. :D

    If you even menage to do that, it will definitely kill your game at that point, even on an iPhone4.

    But if you insist, you could try having 50 different actors and make them spawn 1 actor, triggered at the same time. Maybe than it is possible, but, still I don't think so.

    :D
  • AppsRacKAppsRacK Member Posts: 346
    Nobody said it will crash. First and foremost spawning actor continuously is a bad idea already as it will greatly effect your game as GS dont know yet how to release memory properly. So thinking spawning 50 actor in an instant after 0.001 sec. will definitely have a problem. Like i said on my previous post why not just lay it down on the scene rather than spawning it. This way you wont miss an actor coz they are already on the scene.
  • StormtrixStormtrix Member Posts: 256
    question -- what are the actors?? is there a ton of rules in them?
    I just created a simple demo to test it out.. works fine for me.

    Create game attribute - game.spawn (integer)

    Ball Actor (not sure what your actor is)
    Change Attribute: game.spawn To: game.spawn+1
    Change Velocity: Direction: random(0,360), Speed: random(20,150)
    Collide with wall actor

    Spawn Actor Button (not sure how you're wanting to spawn)
    Rule--- Actor receives Touch
    --- Attribute: game.spawn is = or less then 50
    Timer:
    Every .01 seconds (run to completion)
    Spawn Actor: Ball

    Wall Actor
    just put 4 walls up around scene with moveable unchecked.

    If i hold down the spawn button bam.. 50 balls come out..
    but again- if your spawn actors have tons of rules in them, etc. it could definitely
    be a performance problem i'm thinking like the others have stated.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I had a game that spawned 6 or 7 actors to random location every time the object doing the spawning got destroyed. Those 6 or 7 actors at once was a blow to the system. and in one area you had to destroy a lot of those objects one right after another. That setup brought even the mighty iPhone 4 to its knees.

    Just setup at the top of all these objects you plan to spawn a change attribute for the x and y position to be random in a set range and place them in the scene off screen. it will give the same look and save you some memory and frame rate loss. Also depending on what else is in the scene your 50 actors along could cause issues and then adding other actors in with their own rules will bog things down as well.

    Good Luck

    ___________________________________________________________________________________
    TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!

    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • 8x8n88x8n8 Member, PRO Posts: 81
    I've tried doing this kind of thing and I have two recommendations:

    1) Make your timer a lot longer. If the actors are spawning out of the camera range then why have them all at once?

    2) If you need them all at once on the camera scene, you can do a faux pre-load by making them super small and hide them in the corner. Then change their x/y variable and size when the event is triggered.

    3) You can also change the visible variable in spawnedactor.graphics.

    Other than that need more info on exactly what you want to make happen in the game.
  • MammothMammoth Member Posts: 640
    Alright should possibly clarify. I need to spawn 50ish 'rocks' at the beginning of the level in random places.

    Instead of making the levels by hand I want to generate them.
  • BrynjeBamsenBrynjeBamsen Member Posts: 188
    How about just placing the 50 actors out of sight and then move to randome position.
    This should give the effect you are looking for and still good performance.
  • MammothMammoth Member Posts: 640
    Hi guys,

    Ive been prototyping this idea all day. I decided to do most of the levels by hand. This way load times are easier and it gives a 'levels' vibe. Im debating using this technique for a 'sandbox' mode. Ill probably do it ;)

    Thanks for all of your help :)
Sign In or Register to comment.