spawning an actor with a timer

chrsmyschrsmys Member Posts: 23
edited November -1 in Working with GS (Mac)
I have a timer that runs every 5 seconds and when that timer goes off it is supposed to spawn an actor the only problem is it spawns a lot of actors i only want it to spawn one.. am i using this wrong?

Comments

  • chrsmyschrsmys Member Posts: 23
    it is supposed to spawn one every five seconds but every five seconds it spawns a lot of them.
  • rebumprebump Member Posts: 1,058
    Umm, on a PC so I cannot check the rule choices but it sounds like you may be using "For 5 seconds" instead of "Every 5 seconds"? Maybe it was set to that at one time and GS got honked up even though you changed it to "Every"? Maybe delete and re-create the rule?

    Also, is the actor that is going the spawning, is it in the scene only once or multiple times?
  • chrsmyschrsmys Member Posts: 23
    no thats not the problem because it does it every five seconds... is it a problem that i have more than one of those actors on the screen anyway... Does it spawn an actor for every one of those actors on the screen already?
  • rebumprebump Member Posts: 1,058
    Well, whatever actor has that spawn rule in it, for each instance of that actor in the scene, a spawn will occur every 5 seconds (in your rule case).

    Sounds like you may have an enemy spawning more of itself and the spawns just compound over time (or something similar)!?

    Usually, you will create a "scene controller" actor or an "enemy spawner" actor or such that controls certain events in the scene, such as spawning enemies appropriately, respawning the player after death, initialzing the scene's game attributes, background music, handling scene transistions, etc.
  • chrsmyschrsmys Member Posts: 23
    ok that worked but it dosnt seem like the character being spawned follow the same rules as the other actors that are the same
  • rebumprebump Member Posts: 1,058
    Well, it should. If you have one actor that is the spawner and another actor that is being spawned every five seconds by the spawner actor, then all the spawned actors should behave the same as what is defined in the spawned actors prototype's rules/behaviors area barring any position/rotation changes you enact during the spawning of the spawned actor.

    Phrew...that is a whole lot of spawn goin' on.
  • chrsmyschrsmys Member Posts: 23
    I solved the problem the thing that spawned the characters were in a higher layer so that spawned the characters in the higher layer so it made it look like the things weren't following the collision rules.
    thanks for the help
  • chrsmyschrsmys Member Posts: 23
    will this much spawning make it slow on the iphone?
  • rebumprebump Member Posts: 1,058
    Well, I've heard about 20 or less is best but have not tried any of my projects/tests on actual devices yet. Will be soon though.

    You can always manuall place them on the edge of the scene and move them in and out as needed.
  • JGary321JGary321 Member Posts: 1,246
    Spawning unfortunately takes A LOT of resources. I am finishing up a TD game which has waves of 10 monsters. I had to spawn all 10 at once in particular places while a countdown was going on, in order to disguise the lag. I would highly suggest you test yours on the iPhone before doing too much.

    Also keep the rules that are in the actor you are spawning to a minimum. For example, if you have a guy that has a movement rule & then a 'lives' rule. You'll be fine. But if you have a lot of rules like my guys do EVERY spawn will cause the game to hiccup. VERY noticeable.

    What I did on mine was spawn the monsters off screen. ALL at the same time, so there would only be 1 small hiccup. I covered that up by placing a timer at the top of the screen that says "Wave Starts in 3...2...1..." (counts down). So when they actually spawn nothing really is happening on screen, so it SEEMS like it goes off without a hitch.

    I also have it so that when the countdown reaches 0 it makes changes a game.attribute which indicates for the monsters to start moving. So the monster don't move until I tell them to. This way it still looks as if all the monsters a being spawned one after another, yet they aren't. This is just one little trick that had a MAJOR performance boost for me.

    Again if each actor only has a few rules you will be fine spawning them. I spawn my spells, b/c all they really have in them is a movement rule. Hope this helped.
Sign In or Register to comment.