Godot 4.2.2
Question
Many IDEs like IntelliJ let you set “watches” to track the value of an expression that isn’t explicitly defined as a variable in the code. In Godot, the closest thing I’ve found is looking at the remote tree, but that only shows you the properties of a node. What if I want to evaluate an expression like position.distance_to(neighbour.position)
during runtime, without printing it out, to avoid a bunch of print statement I will have to remember to delete later?
I am wondering if this is a feature that exists in the Godot IDE and I just missed it, or if it’s not a thing at all.
If you use C#, this can easily be achieved with any external IDE you use.
If you use GDScript though, I find that simply watching Remote is plenty enough in most cases, and if I need to evaluate an expression somewhere, I can simply set a breakpoint in a more critical part of the code, maybe inside a logic statement to check my expression. And breakpoints, of course, support stepping through the code while execution is paused.
That’s unfortunate, because I want to evaluate the value of an expression as the game is executing, like you would if you were to print it out in _physics_process()
or something. I just don’t want the extraneous print statements.
I suppose a simple solution would be to create a singleton which draws some variables on the screen that you are trying to watch, using a label or a text field. That way you don’t have to fill up the output with print statements.