If you want to see the position of a class that extends Node2D, you can use the self button in the Members category to put it in the inspector. Every class has a member variable called self to refer to the current class. When you click on a value, its complete state displays in the Inspector, even properties from built-in types like Node. The ID is an internal number the engine assigns objects to keep track of them. Godot lists complex objects, like references to other Nodes, in the variables panel as buttons with the name Object ID: #. But you can view those variables using the inspector. Godot does not put variables from its built-in classes, like Node or Object, in this panel, so it doesn’t become crowded. Globals are variables accessible through Autolads, nodes that are accessible globally in the project.Members are variables that are part of the current class or classes it extends.Locals are the variables defined in the current function.The variables area is split into three categories: locals, members, and globals. Clicking on a different line in the Stack Frames switches those variables to the corresponding stack frame. In the bottom right, you can find the list of all variables the debugger can see in the current call stack frame and their values. It is useful when you want to know why you got certain parameters or which conditional block or for loop called the function. If you click on any element in the list, you can see the execution state of each of those function calls. In the screenshot below, it’s the built-in _physics_process. In Godot’s case, this happens when the C++ engine called the function. The compiler traces back to the initial caller and stops when it can’t dig any further. Its callers follow, stacking on top of each other, hence the name. The function in which it paused is at the top. When the program pauses, it lists the lines of code that led to the current function. When reaching a breakpoint or manually pausing execution, it displays Breakpoint instead.īelow the red text, you can find the Stack Frames, also named the call stack. For example, Division by Zero in operator '/'. ![]() If your code runs into an error, it shows the error text instead. In the top left of the Debugger tab, Godot lists why the program paused. The ability to hover variables close to the breakpoint is nice, but you can get much more information from the Debugger panel. In that case, the editor displays whatever the debugger was looking at in the memory, which does not correspond to anything in your game. You can hover over a variable that you have not set yet. If you hover any variable you set before the breakpoint, a popup shows you its current value. The script editor highlights the line and displays a little green arrow above the red square. The execution stops right before the line with the breakpoint. With breakpoints set, once you run your game, it executes until it reaches the line of code. You can press the F9 shortcut key instead. ![]() To set breakpoints, open the script you want to debug, navigate to the line you want to break at, click in the left margin. ![]() It tells you on which line the breakpoint happened, shows you a stack trace, and fills with information about the game’s current state. At this point, the debugger panel displays some information. In Godot, when you test your game, and the compiler reaches a breakpoint, the game pauses. By clicking on Debugger in the bottom panel.Ī breakpoint tells the client running the code to ask the debugger to pause the program’s execution and report to the programmer.By inserting breakpoints in your code in the script editor.In this guide, you’ll learn how, using Godot’s debugger. Wouldn’t it be great if you could pause your game anytime and inspect your values in context?
0 Comments
Leave a Reply. |