+1 vote

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.

in Engine by (825 points)

1 Answer

+1 vote
Best answer

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.

by (28,876 points)
selected by

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.