Timer not updating with changing attribute
BluSpyder
Member Posts: 129
I have an actor that spawns every certain amount of time. I have about 10 of them in the scene so that the spawn is everywhere.
I have my spawners as: every -> game.difficulty (real attribute) -> Spawn actor
And have another actor on the scene changing the game.difficulty to game.difficulty-0.5 every 2 seconds.
The spawners times are not updating. They continue to spawn at the starting number of the difficulty attribute. I have a text display to show the difficulty attribute to make sure it is changing every 2 seconds and it is.
So why aren't my spawner actors spawning at the changing attribute?
I have my spawners as: every -> game.difficulty (real attribute) -> Spawn actor
And have another actor on the scene changing the game.difficulty to game.difficulty-0.5 every 2 seconds.
The spawners times are not updating. They continue to spawn at the starting number of the difficulty attribute. I have a text display to show the difficulty attribute to make sure it is changing every 2 seconds and it is.
So why aren't my spawner actors spawning at the changing attribute?
Comments
I actually already tried what you suggested, but it doesn't seem to work. Once the game.? transitions to the next rule, my spawning looks like it duplicates, as if the previous rule hasn't been shut down.
But also, I did:
if game.? is > 1 and < 1.5 (also tried < or equal to)
every 1 second
spawn
and so on....
timers and an attribute for the time don't get along sometimes....(theres a problem as well with random and your values because random only accepts whole numbers)
A way around it is (I think this is the way, off the top of my head, it's something like this I worked out a while back):
When DifSwitch is false (--- this is a boolean att. switch)
Change DifSwitch to true
When DifSwitch is true
Change Attribute Difficulty to random(1,4)
If Difficulty is 1
Change attribute Difficulty to .5
otherwise
if difficulty is 2
Change attribute Difficulty to 1 ---- etc
Timer: For game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
hope that helps out.
Edit: beaten by TSB! :-)
----------------------------------------------------------------------------
iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
----------------------------------------------------------------------------
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Also, I thought you said timers don't work with attribute times, but it's what you have in your example?
Sorry if I'm completely oblivious to what's going on here lol.
So now you're saying that they spawn faster and faster by .5 second less each time? OK, if I've understood correctly this time ;-) :
When DifSwitch is false (--- this is a boolean att. switch)
Change DifSwitch to true
When DifSwitch is true
Change Attribute Difficulty to Difficulty - .5
Timer: After game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
I think that's right now, fingers crossed...
Edit: no, it's still wrong... I can do this, honest! I did something similar a while back; give me a couple of minutes to think about it...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Edit: so what you're asking for is "Spawn, every 2 seconds, but every certain value minus 0.5 seconds at the same time" ;-)
So get rid of the every 2 seconds, I'd suggest, and spawn every game. or scene.Difficulty...
i'll be back... ;-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I entered your new suggestion. But this still doesn't work. I think it might be because the part where it is changing by -.5 is happening so rapidly that game.difficulty goes from 2 to 0 in like a split second. Do you think placing another timer in one of your attributes might help? Like When switching DifSwitch to true, placing like this:
When DifSwitch is false
AFTER 1 second change DifSwitch to true
?
(i appreciate you working with me)
spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)
When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
Change DifSwitch to true
When DifSwitch is true
Change Attribute Difficulty to Difficulty - .5
Timer: After game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
If you just wanted them to spawn every two seconds that'll be Every 2 seconds, spawn, surely... or I'm still missing something here...
Edit: maybe try putting the initial value of Difficulty higher to something like 5 seconds, then you'll see it in action better, i.e spawning at 5, then 4.5, then 4 seconds, etc.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
At the start of the game, my spawners should spawn an actor every game.difficulty (2 seconds is the start).
But as time goes by I want that rate to go faster. So say every 3 seconds, the attribute (game.difficulty) should decrease from 2 seconds to 1.9 seconds.
So every 3 seconds -> change game.difficulty to game.difficulty-0.1
When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
Change DifSwitch to true
When DifSwitch is true
Change Attribute Difficulty to Difficulty - .5
Timer: After game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
Is the timer INSIDE the (DifSwitch is true) equation?
After 2 seconds: spawn
For 3 seconds : spawn after 2 seconds minus .1 second.
After 3 seconds: spawn after 1.9 minus .1 seconds. It still doesn't make sense to me, I'm sorry...
Perhaps you mean to start the spawning at three seconds - i.e have game.difficulty set to 3 (seconds), spawn, then after 2.9 seconds, spawn, then after 2.8 seconds, spawn, etc? (Or have game.difficulty set to 2 (seconds), spawn, then after 1.9 seconds, spawn, then after 1.8 seconds, spawn, etc?)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
"Is the timer INSIDE the (DifSwitch is true) equation?"
Yes, it is, sorry, a bit clearer: make Difficulty 3 or 2, depending on the start time in seconds you require.
spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)
When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
Change DifSwitch to true
When DifSwitch is true
Change Attribute Difficulty to Difficulty - 0.1
Timer: After game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
So what happens here is it will spawn an actor, then a loop is set up: 2.9 seconds later (if game.Difficulty is set to 3) spawn another actor, then 2.8 seconds after spawn another, then after 2.7 seconds spawn another, etc.
You'll probably need a "stopper", either with a value of max. amount of spawns, or a time stop. So if it's a time stop, it's now:
spawn actor (----another boolean trigger perhaps needed to start this off when you want if its not immediate)
When DifSwitch is false (--- this is a boolean att. switch, set to its default value of false)
Change DifSwitch to true
When DifSwitch is true
ANd when Difficulty > 0
Change Attribute Difficulty to Difficulty - 0.1
Timer: After game.difficulty seconds
spawn actor
Change attribute DifSwitch to false
I guess though you'd want to stop it looping well before Diificulty +.1, so perhaps stop it at a higher time setting.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I tried your equation again, also tried with and without stopper. The spawning still doesn't work. It will spawn the first spawn that is outside of the timer, and then it will do one more spawn and then everything stops. Any idea why?
Ed: Also, I still display the difficulty attribute in text on the scene just to see if it's working. Right at the beginning of the scene, it jumps down 1. So if i set the starting difficulty to 3, it starts on 2, it does it so fast you can't even see it change..
Your first question: if your x and y coordinates in the spawn behaviour are fixed values, then they will be spawning but all in the same place.... because they appear one on top of the other, you wouldn't be seeing them individually. Perhaps put random(64,960) in the x loc. and random(64,704) in they loc.; or whatever numbers you like in the rules of the actor to be spawned in the scene, minimum and maximum places.
2nd question answer: if you're starting difficulty value is 3 and it spawns at 2 seconds, I'm guessing it's because you've put a 1 instead of 0.1, in the line:
Change Attribute Difficulty to Difficulty - 0.1
Hope it sorts it for you.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I checked the value, it's still at -0.1.
I have sort of fixed my issue with a different and junky method. I changed my spawners on my scene to spawn a spawner when difficulty reaches a certain value. ie when difficulty = 1.5, current spawner is destroyed and next spawner is spawned that has a faster rate of spawning actors. It's really confusing to explain lol. I really don't like this method though, in fact I may just trash the game as it seems unsolvable.
----------------------------------------------------------------------------
iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
----------------------------------------------------------------------------
""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
http://dl.dropbox.com/u/14060718/DG spawn faster test.gameproj.zip
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Hey.
@gyroscope
Would you be able to make that dropbox file available again? I am having the same problem
@youdvdk I don't have that demo file but I can suggest a demo I made that allows you to create a variable timer that changes with the value of an attribute: http://forums.gamesalad.com/discussion/comment/464547/#Comment_464547
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi @youdvdk Hopefully the file from @tatiang will be useful too...
Here's the file I made over 2 years ago now.... frightening where time goes....
Hope you find it useful.
P.S Hi guys - been away for a couple of months.... not given up on GSC, just been "spinning other plates"... any excitements happened that I missed?
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks guys. I'll try those out and see if it works!
Is Gamesalad gonna fix this bug?
It's not really a bug. That's how it's supposed to work.
Mental Donkey Games
Website - Facebook - Twitter
+1
Right. And if you think about how that behavior might work, let's say you set the value of the duration to 5 seconds... the behavior starts and waits until 5 seconds have elapsed and then resets the duration again to 5 seconds. This goes on and on. But, wait, I want to use a variable! So I decide to make the duration self.timerDuration. And I set it to 5. So the behavior starts and waits until 5 seconds have elapsed and then resets the duration again to 5 seconds. But at some point during those 5 seconds, I decide to change self.timerDuration to 9. So... does the timer start over and wait for 9 seconds right at that point even though the last cycle didn't get a chance to complete? Or does the timer add time to get up to 9 seconds and wait for that to expire?
I imagine that the reason the (Every ___ seconds) Timer behavior works the way it does is because there isn't really a great answer to those two questions.
Besides, my demo posted above allows you to create a variable timer and it's not that hard to do.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User