Interpolate Based Timer
BarkBarkCo
Member Posts: 1,400
I haven't made the jump to a GS license yet, so I can't test this FPS-wise...
I have a multitude of non-movable actors that need to destroy themselves a few seconds after they spawn; this is a must. I know I can use a timer, but I'm hoping there is a better way.
So far I have tried interpolating one of the unused self attributes like `self.maxspeed` from "0" to "1" and placing the DESTROY behavior inside a rule checking for `self.maxspeed` to equal to "1".
While this gives me the same result game logic wise, I'm wondering if it is more efficient?
I have a multitude of non-movable actors that need to destroy themselves a few seconds after they spawn; this is a must. I know I can use a timer, but I'm hoping there is a better way.
So far I have tried interpolating one of the unused self attributes like `self.maxspeed` from "0" to "1" and placing the DESTROY behavior inside a rule checking for `self.maxspeed` to equal to "1".
While this gives me the same result game logic wise, I'm wondering if it is more efficient?
Comments
This starts running when the game starts.
You can tap into it and use it.
So, in your spawned Actor, create two Attributes:
capturedTime
delay
Than use a Change Attribute and a Rule, like this:
Change Attribute
self.capturedTime To: game.Time
Rule
When all conditions are valid:
game.Time > self.capturedTime+self.delay
-----Destroy Actor
This way you don't need an extra Timer OR an Interpolate behavior.
EDIT: You should totally get the GS license! The GS Viewer app is really cool, and testing on
actual devices is critical during the building of your game. You don't want to strip stuff out at the
last minute.
Thanks! 2 self attributes, a change and a rule is definitely lighter than my method. We should add a note to timer section of the wiki, if it is not already there...