Triggering an event multiple times with an attribute
CSharpMin
Member Posts: 12
In my game, I want a comet to fly by once every time the game.Wave=1.
I can get it to trigger only the first time, but after the hero dies and the wave is reset, it does not recur.
Basically what I want is to trigger EVERY time the Wave=1.
This should be so simple. I thought every time an attribute changes, rules relying on that attributes will be retested. Is this normally the case is there an exception to that?
I'd appreciate any advice or answers.
Best,
Chris
I can get it to trigger only the first time, but after the hero dies and the wave is reset, it does not recur.
Basically what I want is to trigger EVERY time the Wave=1.
This should be so simple. I thought every time an attribute changes, rules relying on that attributes will be retested. Is this normally the case is there an exception to that?
I'd appreciate any advice or answers.
Best,
Chris
Comments
@CSharpMin Hi Chris, are you sure you're setting Wave back to zero immediately the hero dies? Literally at the end of the dying Rules of the hero actor, before changing any scenes, or restarting anything, etc., just put Change Attribute game.Wave=0. See how you go with that.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
change atrivute game.wave=0
sometimes ive noticed, that the attribute never reaches 1 but instantly changes to 0.
Sydney Swans 2014!!
game.Wave is an integer that steps up based on the player's score throughout gameplay, representing a wave of attack. It resets to zero not when the player dies exactly, but rather, after the reset button is pressed and before a difficulty is selected. After the difficulty is selected, game.Wave is set to 1 and gameplay begins.
The Wave is always displayed on the screen, and seems to be correct.
For testing purposes, instead of repeating every wave 1, I tried repeating the action every 8 seconds with a timer. It worked fine, so I know the actor is resetting to start position correctly. Now if I could just get it to work every wave 1.
Rule
Every 0 seconds
If game.wave = 1
Spawn actor comet
The timer will constantly check if game.wave = 1 and will spawn a comet as soon as it hits 1.
Hope that works.
So if you have the following rule:
When game.Number>5
change attribute game.reachedSix to game.reachedSix+1
And game.Number changes from 5 to 6, game.reachedSix will increase by one because the rule state was false but is now true.
But if game.Number then changes from 6 to 7, nothing will happen because the rule state (true) hasn't changed. You'd have to change game.Number to, say, 3 and then back to 7 for game.reachedSix to increase again.
Post a screenshot of your rules and we'll see why it's not working. If the wave is always displayed on screen, at what point are you seeing it go to 0? And have you tried putting Log Debugging Statements in before and after that point to see if they are showing up as expected?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User