How to make a timer stop when it hits a number . (help please)
http_gamesalad
Member Posts: 1,340
I have this interpolating system and it starts at 20 and I don't want it to go past 5 seconds. It's making my objects come faster and faster which makes the game harder
So this is what i did to get speeding up
I made an integer attribute called "faster" & set it to 20.
So I said
1. Timer
2. every 10 seconds do
3. game.faster to game.faster-1
then I have my interpolate rule
1. Rule
2. when game.start = 1
3. interplate self position to -579 for "game.faster" seconds (which starts of at 20 seconds)
I want that timer to stop counting down once it hits , how can I achive this?
I have no clue honestly.
Comments
If Faster <= 5 constrain attribute to 5.
If game.faster is > 5 then . .
"every 10 seconds do 3. game.faster to game.faster-1"
This will mean that the timer will continue to run - even when it's no longer needed - and as well as the timer you will have an additional constrain behaviour, that also constantly runs, you will basically have two fairly resource hungry behaviours constantly fighting each other to produce inactivity . . . . you'd be better off just sticking in a rule that defines when the timer stops, when the rule is met then the timer will no longer run.
@Socks well, I mean if you are trying to save memory. I guess.
I don't get the picture ?
The idea was not to save memory, but to reduce unnecessary processes, which (accumulatively) are what lead to a less than smoothing running game. Like I say if you use something like 'If Faster <= 5 constrain attribute to 5' the timer will continue to run, and you are adding in a (also continuously running) constrain behaviour, it's probably better to just stop the timer.
But your method works just fine too, and would probably be fine in a lot of situations, so try whatever method works for your game.
@Socks so how would I make that timer stop counting down once it hits 5?
Make sure it only operates when the value of the timer is above 5.
If game.faster is > 5 then . .
"every 10 seconds do 3. game.faster to game.faster-1"
@socks thanks bro