How Do you do RANDOM TIMER?

lagunacomputerlagunacomputer Member Posts: 37
edited November -1 in Working with GS (Mac)
I need to move a 'bonus item' actor across the scene at random intervals

how do i do this?

If i create the actor, place him in the scene, then assign a MOVE behavior, it moves as soon as the scene starts. How do I delay this randomly and possibly make it appear again at random?

thank you

Comments

  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    create an integer attribute called 'zero' and give it a value of 0.

    when zero = floor(self.time)%(minimum random number, maximum random number)

    ... move

    This will make it move every (random number) seconds.

    You don't have to add the floor, but i do as it seems to give better results. I think.
  • lagunacomputerlagunacomputer Member Posts: 37
    thanks man.... i will give it a try and post results
  • lagunacomputerlagunacomputer Member Posts: 37
    'floor(self.time)%(1, 10)' doesnt make it appear, what am i doing wrong?
  • lagunacomputerlagunacomputer Member Posts: 37
    is the zero integer global or is it local to the actor?
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    either global or local is ok.

    use change velocity instead of move and it should be ok
  • lagunacomputerlagunacomputer Member Posts: 37
    hmmmmm i cant get it to work. Am I missing a step? What is changing zero from '0'?

    Created game attribute 'zero' with value of 0 as integer.

    Rule:
    When any conditions are valid:
    Attribute game.zero = floor(self.time)%(2,12)

    Move
    Direction 228 relative to actor type additive speed 300

    I feel like I am missing a step, the item will not move.
  • lagunacomputerlagunacomputer Member Posts: 37
    this is how i got it to work. the actor spawns off screen.

    1. created game attribute 'zero' with value of 0 as integer.

    In my actor (bonus item that flys down screen at random intervals)

    2. Change Attribute
    Change Attribute game.zero to random(1,5)

    3. Timer
    After game.zero seconds run to completion checked
    3a. Spawn Actor direction 0 relative to actor, position 273 504 relative to scene
    3b. Move
    Direction 270 relative to actor type additive speed 300 stacked

    I am having an awful time with the TIMERS. they just dont do what i want them to do
  • lagunacomputerlagunacomputer Member Posts: 37
    im finding that you really have to make sure the expression is entered correctly.

    just typing in 'random(45,320)' and doesnt get it.

    you have to choose 'random' from the drop list, then edit the numbers, then put the cursor after the last ) , then hit the green check box.

    then it is entered correctly and works.
  • zombie_farmzombie_farm Member Posts: 33
    I can't get this to work either. I made an actor that should spawn every 1,5 seconds.. it will only spit out the first random number it generated.

    this is how I set it up.

    http://dl.dropbox.com/u/3080162/game_spawnTest.gameproj.zip
  • cwbh10cwbh10 Member Posts: 52
    I would do (Sorry if it was already posted, I didn't read it all) Rule: If time is equal to Random(Min,Max)
Sign In or Register to comment.