Timer issue
keekee312
Member Posts: 91
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
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
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
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 ]
Edit: posting while @synthesis was.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
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 ?
The following put into an actor different from the two spawned actors, out of screen, quite straightforward:
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
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.
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 ]
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
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