does anyone know how to make random items spawn?

TaidakenTaidaken Member Posts: 271
edited November -1 in Working with GS (Mac)
Is anyone able to help me with this problem, i cant seem to figure out how to make a random item appear every now and then after a enemy has been killed. any help would be much appreciated!!

Comments

  • TaidakenTaidaken Member Posts: 271
    or could atleast point me in the right direction to find out how to do it if it can be done..?
  • keekee312keekee312 Member Posts: 91
    i'm looking for something like this too but i don't manage to do it.

    you can maybe destroy an actor when collided and spawn a new actor when an actor is collided ?
  • reddotincreddotinc Member Posts: 653
    every X seconds

    -- change attribute randomSpawn to random(1,5)

    -- if randomSpawn = 1 then

    -- if randomSpawn = 2 then

    ....
  • keekee312keekee312 Member Posts: 91
  • keekee312keekee312 Member Posts: 91
    This is what i've done but it works only once :s
    i mean once because i don't want a timer but the enemy to spawn when the enemy before it touches the ground (like in tetris for instance). And if i use a rule such as when collision with actor ... => change attribute randomSpawn to random(1,5) etc...

    it does it only once :'(
  • synthesissynthesis Member Posts: 1,693
    Put the set of rules inside a boolean wrapper instead of a timer.

    Such as...
    When self.TimerSaysGo = TRUE
    self.randomValue = random (1,10)
    when randomValue=1 then spawn actor 1
    when randomValue=2 then spawn actor 2

    self.TimerSaysGo = FALSE (The last rule)

    Then in a separate rule have this:
    when.TimerSaysGo = FALSE
    then>>>
    after 5 seconds { TimerSaysGo = TRUE }

    This way...only the timer runs when the other rule isn't running.
    Its a loop also...but doesn't require the function to fire inside the timer (which has been known to cause problems if things don't fire exactly in sequence)...but instead fires inside a rule boolean. Its a ping-pong loop...the boolean switch bounces back and forth between the timer and the spawn rule set.

    Try this...it should work for you.
  • keekee312keekee312 Member Posts: 91
    synthesis said:
    Put the set of rules inside a boolean wrapper instead of a timer.

    Such as...
    When self.TimerSaysGo = TRUE
    self.randomValue = random (1,10)
    when randomValue=1 then spawn actor 1
    when randomValue=2 then spawn actor 2

    self.TimerSaysGo = FALSE (The last rule)

    Then in a separate rule have this:
    when.TimerSaysGo = FALSE
    then>>>
    after 5 seconds { TimerSaysGo = TRUE }

    This way...only the timer runs when the other rule isn't running.
    Its a loop also...but doesn't require the function to fire inside the timer (which has been known to cause problems if things don't fire exactly in sequence)...but instead fires inside a rule boolean. Its a ping-pong loop...the boolean switch bounces back and forth between the timer and the spawn rule set.

    Try this...it should work for you.

    Thank you very much for your answer but I still don't manage to make it work, what's going wrong ???

    First I created two attributes in my actor called Spawner (invisible). The first one is a integer called random_value and the 2nd is a boolean called TimerSaysGo.

    In a first rule I have :

    when self.TimerSaysGo is true
    => Change attribute self.random_value to random(1,6)
    => when self.random_value = 1, spwan ennemy 1
    ...
    => when self.random_value = 6, spwan ennemy 6
    Otherwise : Change attribute self.TimerSaysGo to false

    New rule :

    When self.TimerSaysGo is false
    => Timer : after 3 secs, change attribute self.TimerSaysGo to true.

    That's it and nothing works i think something's wrong because instead of having someting TimerSaysGo, i only have self.TimerSaysGo etc..

    Thank you again !
  • keekee312keekee312 Member Posts: 91
    If after "when self.TimerSaysGo is true"
    i put an other condition such as " when collides with actor of tag SQUARE"
    (because the actors to spawn are different squares, and because the invisible actor (spawner) is next to the ground so the square collides it to reach the ground)
    ...

    When i play the game, one square falls down and when it touches the ground (in fact collides with the invisible actor) make an other square fall down but nothing after :(

    WHY ???
Sign In or Register to comment.