I’d like to add some timers to “special abilities” that a player can acquire by picking up certain objects so they can only have the ability for a limited time. I see that timers can be added in a few ways, but am not sure which would be the best for this purpose or which events are needed.
There’re two types of timers: Scene timers and Object timers
- The scene timers exist for this scene, analogous to the scene variables
- Object timers are analogous to the object variables, there will be a timer “inside” each instance. So you can have two enemies with independent “firetime” timers, for example.
There is only one Player instance, so you can use any of the two timer types. Go for the scene timer since it’s easier to debug, I think.
To make a power-up last for 5 seconds, the logic should be:
- At the beginning >> Disable the ability (the ability will be a variable 0 or 1 if it’s disabled or not)
- Player collides with Power-Up >> Enable the ability and reset the “Ability” timer
- “Ability” timer is greater than 5 seconds >> Disable the ability
And the events should be like:
[code]Conditions: At the beginning of the scene
Actions: Do = 0 to the variable “Ability”
Conditions: Player collides with Power_Up
Actions: Do = 1 to the variable “Ability”
Delete object Power_Up
Reset timer “AbilityTimer”
Conditions: Value of timer “AbilityTimer” is greater than 5 seconds
Actions: Do = 0 to the variable “Ability”[/code]
This will give you a system to enable or disable the ability variable, then in other events you can check if the ability is enabled (variable “Ability” = 1) to do cool things as invulnerability, extra damage, etc.
Sweet, I’ll try that. Thank you
OMG, I wasn’t aware there are object timers. That will change everything I’m currently doing. I were creating timers “by hand” with variables for each object
Yeah, object variables was the only way to do it before, object timers were added 4 months ago or so, is pretty new