Topic was automatically imported from the old Question2Answer platform.
Asked By
epark009
I would like to implement a way to call a function repeatedly for a specified duration. For example, when a character gets hit, they will shake randomly for 0.5 seconds. Currently, I have the shake occur in _physics_process that will start and stop based on a boolean, a function that turns off the boolean when the timer runs out, and yet another function for starting the timer and turning on the boolean. Is there a cleaner way to do this? Ideally, the Timer node should just keep running the shake function until it times out, but there doesn’t appear to be a way to do that.
Ideally, the Timer node should just keep running the shake function until it times out, but there doesn’t appear to be a way to do that.
You could have a counter variable that’s initialized to an positive integer and is decremented every time the timer times out. Once it reaches zero, the timer stops.