@@ -50,25 +50,20 @@ Packet scripts are kept small. The `Write` and `Read` methods are generated for
5050Tested and works with up to 500 clients sending positions to each other.
5151
5252### Your First Netcode
53- Create these packets.
5453
5554``` cs
55+ // Packets
5656public partial class CPlayerJoined : ClientPacket
5757{
5858 public string Username { get ; set ; }
5959}
60- ```
6160
62- ``` cs
6361public partial class SPlayerPositions : ServerPacket
6462{
6563 public Dictionary <uint , Vector2 > Positions { get ; set ; }
6664}
67- ```
68-
69- Create the game client.
7065
71- ``` cs
66+ // Client
7267public partial class GameClient : GodotClient
7368{
7469 public GameClient ()
@@ -84,11 +79,8 @@ public partial class GameClient : GodotClient
8479 Send (new CPlayerJoined (" Valk" ));
8580 }
8681}
87- ```
8882
89- Create the game server.
90-
91- ``` cs
83+ // Server
9284public partial class GameServer : GodotServer
9385{
9486 public Dictionary <uint , Vector2 > Players { get ; } = new ();
@@ -108,11 +100,8 @@ public partial class GameServer : GodotServer
108100 Players .Remove (peerId );
109101 }
110102}
111- ```
112-
113- Start the server and client.
114103
115- ``` cs
104+ // World
116105public partial class World : Node
117106{
118107 private const int Port = 25565 ;
@@ -123,6 +112,8 @@ public partial class World : Node
123112 public override void _Ready ()
124113 {
125114 _net = new Net <GameClient , GameServer >();
115+
116+ // Start server and client
126117 _net .StartServer (Port );
127118 _net .StartClient (Ip , Port );
128119 }
@@ -164,14 +155,13 @@ public partial class CPacketPlayerPosition
164155
165156If a type is not supported, you will need to manually override ` Write ` and ` Read ` . Manually overriding the methods prevents the source gen from generating anything. You should get a warning in your IDE telling you the type is not supported.
166157
167- | Type | Supported | Example Types | Additional Notes |
168- | ----------------- | --------- | ----------------------------------- | -------------------------------------------------------- |
169- | Primitives | ✅ | ` int ` , ` bool ` , ` ulong ` | |
170- | Vectors & byte[ ] | ✅ | ` Vector2 ` , ` Vector3 ` , ` byte[] ` | |
171- | Generics | ✅ | ` List<List<int>> ` , ` Dictionary<string, List<char>> ` | |
172- | Arrays | ✅ | ` int[] ` , ` bool[] ` | |
173- | Classes & Structs | ✅ | ` PlayerData ` | |
174- | Msc | ❌ | ` HashSet ` , ` PointLight2D ` | These types are too specific and will not be supported. |
158+ | Type | Supported | Example Types |
159+ | ----------------- | --------- | ----------------------------------- |
160+ | Primitives | ✅ | ` int ` , ` bool ` , ` ulong ` |
161+ | Vectors & byte[ ] | ✅ | ` Vector2 ` , ` Vector3 ` , ` byte[] ` |
162+ | Generics | ✅ | ` List<List<int>> ` , ` Dictionary<string, List<char>> ` |
163+ | Arrays | ✅ | ` int[] ` , ` bool[] ` |
164+ | Classes & Structs | ✅ | ` PlayerData ` |
175165
176166You have full control over the order of which data gets sent when you override ` Write ` and ` Read ` .
177167
@@ -316,8 +306,6 @@ public partial class Player : Node
316306
317307### Visual Debugging
318308
319- Visual in-game debugging!
320-
321309https://github.com/user-attachments/assets/1fe282b9-f044-42cd-b9be-0e26f20b1aa6
322310
323311https://github.com/user-attachments/assets/2f44ae8e-0c99-4bd2-b15f-a72a70ffaa74
@@ -361,28 +349,27 @@ public class PlayerMovementComponent
361349
362350#### Supported Members
363351
364- | Member Type | Supported | Example Types | Additional Notes |
365- | -------------------| ------------| -----------------------------------------------| -----------------------------------------------------------------------|
366- | ** Numericals** | ✅ | ` int ` , ` float ` , ` double ` | All numerical types are supported |
367- | ** Enums** | ✅ | ` Direction ` , ` Colors ` | All enum types are supported |
368- | ** Booleans** | ✅ | ` bool ` | |
369- | ** Strings** | ✅ | ` string ` | |
370- | ** Color** | ✅ | ` Color ` | |
371- | ** Vectors** | ✅ | ` Vector2 ` , ` Vector2I ` , ` Vector3 ` , ` Vector3I ` , ` Vector4 ` , ` Vector4I ` | |
372- | ** Quaternion** | ✅ | ` Quaternion ` | |
373- | ** NodePath** | ✅ | ` NodePath ` | |
374- | ** StringName** | ✅ | ` StringName ` | |
375- | ** Methods** | ✅ | | Method parameters support all listed types here |
376- | ** Static Members** | ✅ | | This includes static methods, fields, and properties |
377- | ** Arrays** | ✅ | ` int[] ` , ` string[] ` , ` Vector2[] ` | Arrays support all listed types here |
378- | ** Lists** | ✅ | ` List<string[]> ` , ` List<Vector2> ` | Lists support all listed types here |
379- | ** Dictionaries** | ✅ | ` Dictionary<List<Color[]>, Vector2> ` | Dictionaries support all listed types here |
380- | ** Structs** | ✅ | ` struct ` | |
381- | ** Classes** | ✅ | ` class ` | |
382- | ** Resources** | ✅ | ` Resource ` | |
383- | ** Godot Array** | ✅ | ` Godot.Collections.Array<int> ` | Both generic and non-generic types are supported. |
384- | ** Godot Dictionary** | ✅ | ` Godot.Collections.Dictionary<int, bool> ` | Both generic and non-generic types are supported. |
385- | ** Godot Classes** | ❌ | ` PointLight2D ` , ` CharacterBody3D ` | |
352+ | Member Type | Supported | Example Types |
353+ | -------------------| ------------| -----------------------------------------------|
354+ | ** Numericals** | ✅ | ` int ` , ` float ` , ` double ` |
355+ | ** Enums** | ✅ | ` Direction ` , ` Colors ` |
356+ | ** Booleans** | ✅ | ` bool ` |
357+ | ** Strings** | ✅ | ` string ` |
358+ | ** Color** | ✅ | ` Color ` |
359+ | ** Vectors** | ✅ | ` Vector2 ` , ` Vector2I ` |
360+ | ** Quaternion** | ✅ | ` Quaternion ` |
361+ | ** NodePath** | ✅ | ` NodePath ` |
362+ | ** StringName** | ✅ | ` StringName ` |
363+ | ** Methods** | ✅ | |
364+ | ** Static Members** | ✅ | |
365+ | ** Arrays** | ✅ | ` int[] ` , ` string[] ` , ` Vector2[] ` |
366+ | ** Lists** | ✅ | ` List<string[]> ` , ` List<Vector2> ` |
367+ | ** Dictionaries** | ✅ | ` Dictionary<List<Color[]>, Vector2> ` |
368+ | ** Structs** | ✅ | ` struct ` |
369+ | ** Classes** | ✅ | ` class ` |
370+ | ** Resources** | ✅ | ` Resource ` |
371+ | ** Godot Array** | ✅ | ` Godot.Collections.Array<int> ` |
372+ | ** Godot Dictionary** | ✅ | ` Godot.Collections.Dictionary<int, bool> ` |
386373
387374> [ !NOTE]
388375> No mouse interactions have been implemented in 3D, so you will only be able to use it for read only.
@@ -457,8 +444,6 @@ private void CommandDebug(string[] args)
457444}
458445```
459446
460- <img width =" 344 " height =" 330 " alt =" image " src =" https://github.com/user-attachments/assets/d5ccf33f-316a-44ca-9950-8898a6ee14e3 " />
461-
462447## Utilities
463448
464449### Improved Debugger Dock
@@ -533,9 +518,6 @@ public partial class Player : Node
533518Player player = Game .Services .Get <Player >();
534519```
535520
536- > [ !TIP]
537- > Runtime framework services are exposed via ` Game ` . Use ` Game.OptionsManager ` for updates, ` Game.Options.Settings ` for reads, and ` Game.Application.ExitGameAsync() ` for shutdown.
538-
539521### Custom Main Run Args
540522
541523In Godot top left ` Debug > Customize Run Instances... ` there are custom defined arguments you can use.
0 commit comments