Random spawn

liamoliamo Member Posts: 191
edited November -1 in Working with GS (Mac)
Hi guys, can somebody give me the code for random spawning along the x axis only with a random timer. thanks.

Comments

  • liamoliamo Member Posts: 191
    Bump
  • old_kipperold_kipper Member Posts: 1,420
    The only minor trick with this one is to reset the random time so it spawns at different interval each time.

    so with actor 1-

    create a self boolean attribute 'fire' (set it true when you like but to test it leave it true).

    rule one when self attribute fire is true

    timer random(min,max)

    spawn (actor 2?) at position x random(min,max)

    change attribute self fire to false

    rule 2

    when attribute self fire is false

    timer after 0.1

    change attribute self fire true

    hope that helps

    kipper
  • liamoliamo Member Posts: 191
    This may sound dum, it probably is, but do I keep the min, max and put numbers with them, or do I delete min, max like I see in lots of tutorials and just put the numbers eg. 10,100
  • old_kipperold_kipper Member Posts: 1,420
    the min and max for the timer is the min and max for the time YOU want as the gap between spawns. So if you want it to spawn at gaps between 1 and 4 seconds you set it to random(1,4).

    the random in the x pos is for how far along the x you want the spawned actors to appear. so you might want it something like random(32,460).

    cheers and we all have to learn.
  • liamoliamo Member Posts: 191
    Do I need the fire attribute because I'm spawning pits and obstacles, I have an attribute called started and when the game starts it changes to true. There are 3 obstacles, a pit, a rock and a bird. Thanks heaps for your help, random is new to me.
  • liamoliamo Member Posts: 191
    BUMP
  • liamoliamo Member Posts: 191
    nevermind.
  • liamoliamo Member Posts: 191
Sign In or Register to comment.