-
Notifications
You must be signed in to change notification settings - Fork 23
How to debug your game net code
To debug your game net code, you can use the built-in debugger, that will allow you to fetch node data per each frame.
As the first thing you want to enable the SceneSynchronizerDebugger
as by default it's disabled; you can enable it by set the godot project settings property NetworkSynchronizer/debugger/dump_enabled
to true
.
By default, the debugger fetches a bunch of useful information from all the networked nodes; however, if you want to also fetch information from some other nodes you can add the class name to the project settings NetworkSynchronizer/debugger/dump_classes
: the debugger will fetch information from any node that inherits the classes you add to that list.
Now that the debugger is enabled, all you have to do is to open the Client/Server instances and reproduce the behaviour you want to analyze. Once you have reproduced the issue, you can simply close the instances.
Now navigate to your godot/bin
directory to find a newly created directory: net-sync-debugs/dump
. Navigate into it.
There you will find the debugger.py
(a python UI to help you navigate the debugged frames).
Launch it using the command python debugger.py
Note, to use the UI you must install:
- Install python
- Install pip
- Install PySimpleGUI:
pip install pysymplegui
- Install Tkinter:
- Install Tkinter app:
- Fedora:
sudo dnf install python3-tkinter
- Ubuntu:
sudo apt-get install python3-tk
- Install python library:
pip install tk
The UI is composed by 5 panels.
- Frame list: Show all the frames + a small summary.
- Node list: Shows all the nodes captured in that frame.
- Error detection area: The debugger has the ability to detects some malfunctioning; In that case, an error about it will appear there.
- Node dump: This area shows the node variable dumping.
- Log output: Here you will find the log output generated by the selected node on the given frame. (Here you can find a bunch of messages, warnings, errors, but also the data buffer write and read).
You can use the first panel to navigate the frames (You can use the arrows too). The next thing you want to do is to select the nodes to debug (using the 2nd panel); essentially here you are filtering the nodes.
The 4th panel shows the nodes status: essentially the debugger dumps the node variables before starting the frame and after.
The 4th panel shows the nodes' status: essentially, the debugger dumps the node variables before starting the frame and after.
🔄 This symbol is used to signal that the variable is tracked by the
NetworkSynchronizer
.
⚠️ This symbol is used to signal that the value is different between server and client.
The log view is really interesting. By organizing the log per node, it tells a lot of useful information about the processing, on both serer and client.
For example, in this view you can compare the data written on the DataBuffer
on client with the one read on the server, and figure out why the node de-sync.
You can actively interact with the debugger, even from GDScript. Here is a list of API to write messages; that can be used to mark important information about the game play, that will give even more insight about the processing.
void debug_print(Node *p_node, const String &p_message, bool p_silent = false);
void debug_warning(Node *p_node, const String &p_message, bool p_silent = false);
void debug_error(Node *p_node, const String &p_message, bool p_silent = false);
Community & Support
- Open an issue
- Start a new discussion