Random Spawn Time

charliehgreencharliehgreen ArizonaMember Posts: 233
Hello,

So I'm having issue where I can't get enemies to spawn at a random time.
For example. I have the rule set to:

Every random(1,5) seconds
__Spawn Actor

But once I'm in the game, the enemy is being spawned every 5 seconds.
I would think from this code, he would spawn randomly every 1 - 5 seconds.
Correct? Guess not :(

Code Below:

photo ScreenShot2013-09-03at30220PM_zps5587a129.png

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Try doing every second but add a rule around the spawn to only spawn if random(1,5) = 1 or random(1,5) <= 2 if you want to increase the chances
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I should have also have said that even if the random thing you've set up works it's only going to pick a random number once when the actor is loaded and the timer will run off that one number until you restart the game and the actor is reloaded.
  • VolontaArtsVolontaArts Member Posts: 510
    I should have also have said that even if the random thing you've set up works it's only going to pick a random number once when the actor is loaded and the timer will run off that one number until you restart the game and the actor is reloaded.
    if i understand what your saying correctly maybe this may help him???

    this was posted to my thread by @ericzingeler for making every spawn actor his own.

    my example was, spawn an actor...that actor is controled by player. then when that actor collides, spawn a new actor and the play now controls that one.

    so @ericzingler recommended
    A great way to independently control spawned actors is to give them a unique identity.

    The easiest way to do this is like so:

    Game attributes:

    actorIndex (index type attribute)
    activeActor (index type attribute)

    Actor attribute:

    myID (index)

    beavers inside actor (at top, outside of rules):

    change game.actorIndex to: game.actorIndex + 1
    change myID to: game.actorIndex

    Ok, now your spawned actors are unique. At this point, just set game.activeActor the ID number of the actor you want to control, then inside the actor do this:

    if myID = game.activeActor

    [control behaviors here]




    sorry if this is way off topic, i am very new to this but try and give back anyways because theres a lot of helpful people here.
  • VolontaArtsVolontaArts Member Posts: 510
    oh and maybe you can make a table with the different seconds, 1,2,3,4,5
    then randomize the rows. its the same thing and bit more work but since ur timer isnt working.
    btw i had a timer set up once that kept messing up on me. once i figured another way. it worked out perfect
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited September 2013

    Hi @charliehgreen

    It used to be that a random in a Timer set to Every only registered once but then I thought that had been fixed... so it seems that's wrong...

    So, you have to keep the random seconds outside of the Timer, to be put into an attribute to use, and not have the Timer set to Every - just to After - then set up a loop mechanism with a boolean.

    Here's a little test to show you what I mean (btw, I made the attributes as game ones, just make yours scene ones if you want.)

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

  • charliehgreencharliehgreen ArizonaMember Posts: 233
    Thanks all..
    I'm going to test @gyroscope sample.

    Thanks again
  • sariflucasarifluca Member Posts: 3

    i think all you need to do is just change it so the timer says after, insert a random function and choose your time frame, not sure if thats whats already been said

  • NNterprisesNNterprises Member, PRO Posts: 387

    Good work @sarifluca .

    But this post was from 3 years ago so GS may not have had the same functionality and some of these users probably don't exist anymore... Just remember that when you're looking for tips, make sure theyre recent as a lot has changed!

  • smurftedsmurfted Member, PRO Posts: 570
    edited November 2017

    This is still relevant now.

    If you use the timer on "every" with a random amount. It only calculates the random once. Then uses that number forever, not very random at all.

    Thankyou gyroscope!

Sign In or Register to comment.