Hi everyone! I’m sharing a simple but handy node and script I created using GDScript to automatically turn off a switch (boolean) after a set duration.
By placing this as a child of any GameObject, it detects when a specific property is set to true and flips it back to false after a designated number of seconds.
Demo:
Why I made this: While you can achieve the same result by creating child objects with VisualScript, I wanted a single-node solution to keep the scene tree clean. It’s particularly useful for managing manual invincibility frames or handling switches for transitions from AnyState in AnimationTrees.
Downloads:
- switch_timer.gd (2.2 KB)
- switch_timer.tscn (242 Bytes)
How to use:
- Import
switch_timer.gdandswitch_timer.tscninto your FileSystem. - Add
switch_timer.tscnas a child of the GameObject you want to monitor. - Specify the target variable name and the delay time in the inspector, and you’re good to go!