Skip to content

Instantly share code, notes, and snippets.

@WolfgangSenff
Created April 16, 2025 14:56
Show Gist options
  • Save WolfgangSenff/95ef44e4b6052f3071374c3398ee870c to your computer and use it in GitHub Desktop.
Save WolfgangSenff/95ef44e4b6052f3071374c3398ee870c to your computer and use it in GitHub Desktop.
Variable checker for Godot
# This useful little class can be created in a node and it'll make it so you can, on a timer, check the value of a specific variable by simply passing in the variable name
class_name VariableChecker
extends Timer
func _init(check_time: float, variable_name: String, check_against: Node) -> void:
wait_time = check_time
autostart = true
timeout.connect(func(): print(check_against[variable_name]))
check_against.add_child(self)
# Usage
var var_checker
func _ready() -> void:
var_checker = VariableChecker.new(2.0, "velocity", self) # Every 2 seconds it prints the current velocity of this CharacterBody
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment