Creating a spawn actor that will increase spawn rate with time

sandmansandman Member Posts: 14
edited June 2012 in Working with GS (Mac)
Hi all,

I want to create an actor that spawns actors at random intervals.
My questions are:
1- How can I make the rate of spawning increase as time goes by?
2- How to prevent the actor from spawning two actors at the same time?



Answers

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Hi,

    You can create an integer attribute called HowManySeconds and set it to 2, for example.
    Then put a timer in an actor that says:

    Timer, every (hit the little "e") game.HowManySeconds
    Spawn actor: (Whatever)
    Plug in your X and Y cords.

    Next, in an actor off screen so the player cannot see it, put:

    Timer:
    Every 30 seconds (or whatever)
    Change attribute: game.HowManySeconds to 1

    This will change the spawn rate from 2 seconds to one second. You can play and tweak this of course.

    Hope this helps.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2012

    Hi @sandman

    As far as I can make out, two of your requests: "spawn actors at random intervals" and spawning increasing as time goes by" are at odds with each other....

    So I'm going to assume that you won't need any random here, just spawn rate increasing, one spawned at a time, and so that there is no multiple spawning, as you also want.

    I'm also assuming that when it reaches the fastest spawn rate possible without more than one actor spawning at the same time, you can, at the end, still have spawns but at a regular interval... hope I've explained that well enough, please correct me if i'm wrong.

    OK, if that's what you're after, make an integer attribute called CountDown, its value set to 20, as an example. (All figures will have to be adjusted depending on the rate increase and start interval you're after).

    Then make another attribute, index this time, let's call it DecTime. Set it's value to 5.25 (assuming the first interval is 5 seconds, and the speedup of time is less .25 second every time).

    So, also assuming you want this to happen straightaway when the scene starts, put an actor onscreen but outside of the play area, with Rules:

    Spawn Actor relative to scene
    Positions set to random
    Rule
    When scene.countdown = 0
    Timer Every .25 second
    Spawn Actor relative to scene
    Positions set to random

    And in the prototype of the actor you want spawned:

    Change attribute scene.Countdown to Countdown -1
    Change attribute scene.DecTime to DecTime -0.25

    Rule: When scene.Countdown >0
    Timer After scene.DecTime
    Spawn Actor relative to scene
    Positions set to random

    Hope that's the sort of thing you're after...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • sandmansandman Member Posts: 14
    @gyroscope
    @Braydon_SFX

    Hey guys,

    Thank you for the feedback.
    I'll try your suggestions and see if it works.

    I don't know if I was clear enough though.

    I want to create one actor that will spawn: for example (bananas, apples) at random times.
    - I created a timer. Inside the timer I did the following:
    --- spawn: random(2,10) -- actor: bananas
    --- spawn: random(2,10) -- actor: apples

    Up untill here it works fine, or at least its doing what I need it to do ;-)

    What I need to do is after say one minute the random rate is(2,7), after two minutes (2,5)
    so more actors are created in a given time, but still random.

    -Regarding The overlapping:
    I'm afraid the actor will create the two actors(apples,bananas) at the same time since its random and I want to prevent it from doing so..


Sign In or Register to comment.