Timer issue

keekee312keekee312 Member Posts: 91
edited November -1 in Working with GS (Mac)
I have a problem (again !!!) with the timer.

This is my rules : I have an invisible actor called Spawner put into the scene.

Every second : change attribute self.enemyType to random(1,10)

RULE : when self.enemyType = 1 then spawn actor 1
RULE : when self.enemyType > 1 then spawn actor 2

But both actors are spawn every 5 sec or more I don't know why, everything I do in GS don't work :(

Thanks for help

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi keekee312, could it be that you haven't put where the actors should spawn? So they might be spawning, but outside of the visible screen area.

    Or if you've done this, maybe make sure Relative to: is set to Scene? And finally, a long-shot, make sure Run to completion is checked in the Timer.

    Hope this helps. :–]

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

  • keekee312keekee312 Member Posts: 91
    gyroscope said:
    Hi keekee312, could it be that you haven't put where the actors should spawn? So they might be spawning, but outside of the visible screen area.

    Or if you've done this, maybe make sure Relative to: is set to Scene? And finally, a long-shot, make sure Run to completion is checked in the Timer.

    Hope this helps. :–]

    Thanks for help. Everything you said was already done so I still have my problem :(
  • synthesissynthesis Member Posts: 1,693
    Try integrating a TRUE/FALSE boolean switch into it.
    Only execute the rules when the boolean is TRUE and then make the last rule a FALSE.

    When False...execute the timer (don't use a loop timer...but rather a delay timer).

    This will allow the actor to do a "ping-pong" style routine rather than a loop. Loops can be tricky if you don't sequence them perfectly...and everything happens in microseconds...But using switch booleans...you can guarantee that the sequence of operations of the function happen in the correct step order.

    Something like this:

    RULE1: when spawnAnActor=FALSE
    ....self.enemyType = random(1,10)
    timer: after X seconds >>
    ....spawnAnActor=TRUE
    [ end or RULE1 ]

    RULE2: when spawnAnActor=TRUE
    .....RULE3: when self.enemyType = 1 then
    ...........spawn actor1
    .....Otherwise
    ...........spawn actor 2
    [ end or RULE3 ]

    spawnAnActor=FALSE
    [ end or RULE2 ]
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hmm, annoying for you, I'm sure. How about trying When attribute self.enemyType =1 then spawn actor 1, then in the otherwise bit, spawn actor2?

    Edit: posting while @synthesis was.

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

  • keekee312keekee312 Member Posts: 91
    gyroscope said:
    Hmm, annoying for you, I'm sure. How about trying When attribute self.enemyType =1 then spawn actor 1, then in the otherwise bit, spawn actor2?

    Edit: posting while @synthesis was.

    I did it before but it didn't work. I'm going to try as synthesis said
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    keekee312 said:
    I did it before but it didn't work. I'm going to try as synthesis said

    That's good.

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

  • keekee312keekee312 Member Posts: 91
    synthesis said:
    Try integrating a TRUE/FALSE boolean switch into it.
    Only execute the rules when the boolean is TRUE and then make the last rule a FALSE.

    When False...execute the timer (don't use a loop timer...but rather a delay timer).

    This will allow the actor to do a "ping-pong" style routine rather than a loop. Loops can be tricky if you don't sequence them perfectly...and everything happens in microseconds...But using switch booleans...you can guarantee that the sequence of operations of the function happen in the correct step order.

    Something like this:

    RULE1: when spawnAnActor=FALSE
    ....self.enemyType = random(1,10)
    timer: after X seconds >>
    ....spawnAnActor=TRUE
    [ end or RULE1 ]

    RULE2: when spawnAnActor=TRUE
    .....RULE3: when self.enemyType = 1 then
    ...........spawn actor1
    .....Otherwise
    ...........spawn actor 2
    [ end or RULE3 ]

    spawnAnActor=FALSE
    [ end or RULE2 ]

    I might be retarded but it stil doesn't work :s Tell me if everything is ok

    I created 2 game attributes (an integer and a boolean) Their value is default so 0 and unchecked. The first one is enemyType and the second one SpawnAnActor.

    In an invisible actor called spawner and put into the scene I made these rules :

    RULE 1:
    When game.spawnanenemy is false
    => change game.enemyType to random(1,10)
    => Timer : for 5 secs, change attribute spawnanactor to true

    RULE 2:
    When game.spawnanactor is true
    and when game.enemytype = 1
    => spawn actor 1 (position x : random(30,800), position y : 700)
    otherwise : spawn actor 2 => spawn actor 1 (position x : random(30,800), position y : 600)
    (I'm in Ipad landscape view)

    RULE 3 :
    Change attribute : game.spawnanactor to false

    So ?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi, with respect to synthesis, i've got a test working without the boolean (I've added 2 and 3 to the first actor, so there's more occurrence, to check it was working, but you can delete them, of course). I know you tried this way, but as I say, it seems to be working OK.

    The following put into an actor different from the two spawned actors, out of screen, quite straightforward:

    Photobucket

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

  • synthesissynthesis Member Posts: 1,693
    @keekee...

    Your when enemy type rule should be INSIDE rule 2...not part of the same rule.
    Look CLOSELY at my example...you did not replicate it exactly.

    There are only 2 rule sets. Rule 3 is inside rule 2.

    @gyro...
    what you are doing is fine...
    but what I was pointing towards was avoiding the Loop timer...which can be cumbersome on the GE. Plus using switch booleans is a good skill to develop...as it helps one avoid bugs.
  • synthesissynthesis Member Posts: 1,693
    LIKE THIS!!!

    RULE 1:
    When game.spawnanenemy is false
    => change game.enemyType to random(1,10)
    => Timer : for 5 secs, change attribute spawnanactor to true

    RULE 2:
    When game.spawnanactor is true

    RULE 2A (INSIDE RULE 2):
    when game.enemytype = 1
    => spawn actor 1 (position x : random(30,800), position y : 700)
    otherwise : spawn actor 2 (position x : random(30,800), position y : 600)
    [ END RULE 2A ]

    Change attribute : game.spawnanactor to false
    [ END RULE 2 ]
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    synthesis said:

    @gyro...
    what you are doing is fine...
    but what I was pointing towards was avoiding the Loop timer...which can be cumbersome on the GE. Plus using switch booleans is a good skill to develop...as it helps one avoid bugs.

    Understood, thank you synthesis. :-)

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

  • keekee312keekee312 Member Posts: 91
    What the heck ! I did like you both said but it still doesn't work. It should have an other problem. I'll try many things and i'll tell you..
  • keekee312keekee312 Member Posts: 91
    keekee312 said:
    What the heck ! I did like you both said but it still doesn't work. It should have an other problem. I'll try many things and i'll tell you..

    So, gyroscope idea now works (yesterday no, strange) but when the second actor is spawn then nothing happens anymore.
    And for synthesis', I can "make it work" only in the actor Spawner and not an other one (it makes the GS shutdown, but it doesn't really work because only one actor is spawn then nothing... I really don't understand what's happen, I'm lost.

    Thanks for help
Sign In or Register to comment.