I need that when certain conditions are met, “_process” in the script paused for about 2 seconds. I am making a switch for the light, and the problem arose that without this pause The state of the switch changes several times per press. And I want to “recharge” the switch.
The problem is that I don’t know how to tell the code to count down two seconds! It’s not hard to create logical variables. But I don’t know any time-related functions. And how do I use the “timer” object I still don’t understand.
func pause_process(pause_time):
set_process(false)
await get_tree().create_timer(pause_time).timeout # create a timer and wait for it to time out
set_process(true)
Or with a callback tween like this:
func pause_process(pause_time):
set_process(false)
create_tween().tween_callback(set_process.bind(true)).set_delay(pause_time) # call set_process(true) after a certain amount of delay