watching the value of a function's private variable?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

I had a perfectly almost running game. I added a few features and BAM! It’s playing up on me.

I’m trying my hardest to debug it but am having to create labels on screen that represent variables etc. This is hard when I swap to another scene and want to know what the function’s PRIVATE variable was in the ANOTHER scene (the last scene).

Is there any kind of debugging / watch features? I’m pretty new to this so am not sure on the terminology but I’d sure love to be able to watch the values that I consider important as they change.

Any help greatly appreciated.

:bust_in_silhouette: Reply From: Zylann

You can usually place breakpoints in your code by clicking on the left margin or the script editor menu. The engine will suspend your game when the line is reached, and you can inspect the value of variables in that suspended state.

I believe you can also pause the game (button next to Play) and see the state of your scene in the Info debugger panel: the hierarchy of nodes, and possibly the value of their variables.

If you can’t suspend the game then printing is your only option.

Some idea: conditionnal/non-breaking breakpoints that print messages would be handy because it would save time if the game runs on device and live script modification doesn’t works, however it’s not supported and hasn’t even be suggested, given how few people know it exists in some IDEs.

Thank you for that, that’s VERY helpful (clicking in the margin of the editor to get a breakpoint).

It’s not as advanced as other editors I’ve seen of course but I do like how the “Stack Frames” part of the Debugger allows me to step through each functions history to see how I got somewhere.

That should make a big difference. It’s far from perfect but you’ve really helped me out. Thanks again.

Robster | 2016-09-22 00:27