-
Notifications
You must be signed in to change notification settings - Fork 17
Multiplayer Scripting
This page is a work in progress
If you are the one hosting the game server, there are 3 threads, the game client thread, the game server thread and the Godot thread. If you are a client joining a server, there are only 2 threads, the game client thread and the Godot thread.
Directly accessing variables from other threads is a violation of thread safety so rather Concurrent Queues should be used to communicate between them.
Violating thread safety can lead to frequent random game crashes with usually no errors in console making these types of issues extremely hard to track down when they start acting up.
Specific opcode messages can be ignored if you don't want to be spammed when debugging a specific part of the netcode.
In the future a checkbox option will be added to completely turn opcode logging off.
FYI: You will also notice there is a Auto Host Join
property, use this to make setting up multiplayer testing environments less tedious to setup. For example if this property is enabled then if the game is ran through the editor then it will auto setup a host client and if the game is ran through a exported release it will auto connect to the server as a client.
These packets are auto pushed from the game client thread to the Godot thread. This is usually what the developer will want in most cases but sometimes the dev will also need access to the game client thread or just the game client thread by itself. I'm not really sure what to default this to right now.