-
Notifications
You must be signed in to change notification settings - Fork 13
Multiplayer
This page is WIP.
Multiplayer.Preview.mp4
Important
If you are running Mac or Linux you may need a Custom ENet Build
Note
Each packet comes with a small overhead, either 1 or 2 bytes, depending on configured reliability and a one-byte opcode to identify its purpose. Everything else in the packet is strictly the data we send.
-
Do not directly access properties or methods across threads unless they are explicitly marked as thread safe. Not following thread safety will result in random crashes with no errors logged to the console. Things on the client thread should stay on the client thread and things on the server thread should stay on the server thread. If you need to communicate between them use the existing ConcurrentQueues.
-
A common oversight is using one data type for writing and another for reading. For example, if you have an integer
playerCountand you write it withwriter.Write(playerCount), but then read it as a byte withplayerCount = reader.ReadByte(), the data will be malformed becauseplayerCountwasn't converted to a byte prior to writing. To avoid this, ensure you cast your data to the correct type before writing, even if it feels redundant.
Example netcode has been provided in res://Framework/GodotUtils/Netcode/Sandbox/TopDown/World.tscn
Found information that needs to be updated in the wiki? Or have a suggestion for a new feature? Or maybe you found a bug? Want to contribute but have no idea where to start? Send me a message over Discord, my username is valky5.