Last active
August 29, 2023 00:54
-
-
Save mhilbrunner/31e79a20a11d7e5f0daf2ab92251d2d9 to your computer and use it in GitHub Desktop.
Revisions
-
mhilbrunner revised this gist
Oct 6, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,13 @@ **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** **Last updated: 2021-10-06** Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): - https://godotengine.org/article/multiplayer-changes-godot-4-0-report-1 - https://github.com/godotengine/godot/commit/24a949ea1154a2298e6898c53fdb75178affe098 - Multiplayer renames/simplification: https://github.com/godotengine/godot/pull/52480 - Spawn/despawn sync: https://github.com/godotengine/godot/pull/51097 and https://github.com/godotengine/godot/pull/51534 - State sync: https://github.com/godotengine/godot/pull/51788 -
mhilbrunner revised this gist
Sep 16, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls - RSETs got removed: https://github.com/godotengine/godot/pull/49221 - Tons of fixes and improvements :) - MultiplayerAPI is now used instead of things like signals being on the SceneTree directly: https://docs.godotengine.org/de/latest/classes/class_multiplayerapi.html - `network` has been removed where possible in MultiplayerAPI due to redundancy, e.g. `multiplayer.is_network_server()` is now just `multiplayer.is_server()`, exception are the methods in `Node`, where `multiplayer` is used instead, see below: - `Node.set_network_master()` is now `Node.set_multiplayer_authority()` - The `TransferMode` and `RPCMode` enums are now bound as core constants, which means instead of `MultiplayerAPI.RPC_MODE_ANY` you can just use `RPC_MODE_ANY` -
mhilbrunner revised this gist
Sep 16, 2021 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): - https://godotengine.org/article/multiplayer-changes-godot-4-0-report-1 - Multiplayer renames/simplification: https://github.com/godotengine/godot/pull/52480 - Spawn/despawn sync: https://github.com/godotengine/godot/pull/51097 and https://github.com/godotengine/godot/pull/51534 - State sync: https://github.com/godotengine/godot/pull/51788 - Renames: https://github.com/godotengine/godot/pull/51481 and https://github.com/godotengine/godot/pull/50398 @@ -18,7 +19,8 @@ Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls - RSETs got removed: https://github.com/godotengine/godot/pull/49221 - Tons of fixes and improvements :) - MultiplayerAPI is now used instead of things like signals being on the SceneTree directly: https://docs.godotengine.org/de/latest/classes/class_multiplayerapi.html - `network` has been removed where possible in MultiplayerAPI due to redundancy, e.g. `multiplayer.is_network_server()` is now just `multiplayer.is_server()` - `Node.set_network_master()` is now `Node.set_multiplayer_authority()` - The `TransferMode` and `RPCMode` enums are now bound as core constants, which means instead of `MultiplayerAPI.RPC_MODE_ANY` you can just use `RPC_MODE_ANY` # Setup peer -
mhilbrunner revised this gist
Sep 16, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** **Last updated: 2021-09-17** Ask questions in `#networking` on chat.godotengine.org -
mhilbrunner revised this gist
Sep 16, 2021 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls - Tons of fixes and improvements :) - MultiplayerAPI is now used instead of things like signals being on the SceneTree directly: https://docs.godotengine.org/de/latest/classes/class_multiplayerapi.html - `Node.set_network_master()` is now `Node.set_network_authority()` - The `TransferMode` and `RPCMode` enums are now bound as core constants, which means instead of `MultiplayerAPI.RPC_MODE_ANY` you can just use `RPC_MODE_ANY` # Setup peer @@ -69,6 +70,11 @@ test() `mastersync` would now be `@rpc(auth, sync)`. You can also still use `Node.rpc_config()`: ``` rpc_config(&'move_and_slide', RPC_MODE_ANY) ``` # Using the new multiplayer spawning and syncing This enabled scene spawning/syncing replication for the scenes "Player" and "Box". For both, spawns are synced, so if you `.instantiate()` them and add them to the scene, that gets done on all other peers automatically as well, same for `.queue_free()`ing/deleting them. -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,8 @@ peer.peer_connected.connect(_peer_connected) peer.peer_disconnected.connect(_peer_disconnected) peer.connection_failed.connect(_connection_failed) peer.connection_succeeded.connect(_connection_succeeded) # (You can also connect to get_tree().multiplayer.peer_connected and so on, # that works even while the peer is null) # peer.create_server(SERVER_PORT) peer.create_client(SERVER_IP, SERVER_PORT) -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls - RSETs got removed: https://github.com/godotengine/godot/pull/49221 - Tons of fixes and improvements :) - MultiplayerAPI is now used instead of things like signals being on the SceneTree directly: https://docs.godotengine.org/de/latest/classes/class_multiplayerapi.html - `Node.set_network_master()` is now `Node.set_network_authority()` # Setup peer @@ -40,7 +41,9 @@ peer.create_client(SERVER_IP, SERVER_PORT) get_tree().multiplayer.network_peer = peer ``` # RPCs are @rpc annotations now RSETs are gone, just use RPCs now. You use the `@rpc` annotation to denote RPC functions. You can use arguments with that annotation for configuration, in any order. @@ -90,7 +93,4 @@ func _replication_setup(scene : PackedScene, params : Array, sync : bool = false if sync: # Enable property syncing multiplayer.replicator.sync_config(id, 16, params) ``` -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ peer.peer_connected.connect(_peer_connected) peer.peer_disconnected.connect(_peer_disconnected) peer.connection_failed.connect(_connection_failed) peer.connection_succeeded.connect(_connection_succeeded) # (You can also connect to get_tree().multiplayer.peer_connected and so on, that works even while the peer is null) # peer.create_server(SERVER_PORT) peer.create_client(SERVER_IP, SERVER_PORT) -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,7 @@ Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls - Mesh networking and lowlevel wrappers for ENet: https://github.com/godotengine/godot/pull/50710 - RSETs got removed: https://github.com/godotengine/godot/pull/49221 - Tons of fixes and improvements :) - MultiplayerAPI is now used instead of things like signals being on the SceneTree directly: https://docs.godotengine.org/de/latest/classes/class_multiplayerapi.html # Setup peer @@ -29,6 +30,7 @@ peer.peer_connected.connect(_peer_connected) peer.peer_disconnected.connect(_peer_disconnected) peer.connection_failed.connect(_connection_failed) peer.connection_succeeded.connect(_connection_succeeded) # (you can also connect to get_tree().multiplayer.peer_connected and so on, those work even without the peer) # peer.create_server(SERVER_PORT) peer.create_client(SERVER_IP, SERVER_PORT) -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): - https://godotengine.org/article/multiplayer-changes-godot-4-0-report-1 - Spawn/despawn sync: https://github.com/godotengine/godot/pull/51097 and https://github.com/godotengine/godot/pull/51534 - State sync: https://github.com/godotengine/godot/pull/51788 - Renames: https://github.com/godotengine/godot/pull/51481 and https://github.com/godotengine/godot/pull/50398 - `close_connection()` is silent now: https://github.com/godotengine/godot/pull/52342 @@ -78,7 +78,7 @@ func _replication_setup(scene : PackedScene, params : Array, sync : bool = false # Scenes are identified using the new resource UIDs var id = ResourceLoader.get_resource_uid(scene.resource_path) # Enable spawn/despawn syncing multiplayer.replicator.spawn_config( id, MultiplayerReplicator.REPLICATION_MODE_SERVER, -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,7 +78,7 @@ func _replication_setup(scene : PackedScene, params : Array, sync : bool = false # Scenes are identified using the new resource UIDs var id = ResourceLoader.get_resource_uid(scene.resource_path) # Enable spawn syncing multiplayer.replicator.spawn_config( id, MultiplayerReplicator.REPLICATION_MODE_SERVER, -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,7 @@ For "Player", `position` is kept synced as well, so if you move, `position` gets For real use, you want to use a custom RPC for movement (to be able to interpolate the position and smooth updates). But this is useful to keep less important things synchronized. ``` func _ready(): _replication_setup(Player, ["position"], true) _replication_setup(Box, ["position"]) -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,18 +75,18 @@ func _setup_replication(): _replication_setup(Box, ["position"]) func _replication_setup(scene : PackedScene, params : Array, sync : bool = false): # Scenes are identified using the new resource UIDs var id = ResourceLoader.get_resource_uid(scene.resource_path) # Enabled spawn syncing multiplayer.replicator.spawn_config( id, MultiplayerReplicator.REPLICATION_MODE_SERVER, params ) if sync: # Enable property syncing multiplayer.replicator.sync_config(id, 16, params) ``` -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,7 +65,7 @@ test() # Using the new multiplayer spawning and syncing This enabled scene spawning/syncing replication for the scenes "Player" and "Box". For both, spawns are synced, so if you `.instantiate()` them and add them to the scene, that gets done on all other peers automatically as well, same for `.queue_free()`ing/deleting them. For "Player", `position` is kept synced as well, so if you move, `position` gets updated on peers. For real use, you want to use a custom RPC for movement (to be able to interpolate the position and smooth updates). But this is useful to keep less important things synchronized. -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** **Last updated: 2021-09-04** Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,16 @@ peer.create_client(SERVER_IP, SERVER_PORT) get_tree().multiplayer.network_peer = peer ``` # RPCs are @rpc annotations now (RSETs are gone, just use RPCs now) You use the `@rpc` annotation to denote RPC functions. You can use arguments with that annotation for configuration, in any order. Arguments are: - sync/nosync (whether calls are called locally too, or only remote) - any/auth (whether the RPC can be called by any peer or only `auth`, the authority (previously `master`) - reliable/unreliable/ordered (transfer mode) Examples: `remote func test()` becomes ``` -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,6 +50,8 @@ test() test() ``` `mastersync` would now be `@rpc(auth, sync)`. # Using the new multiplayer spawning and syncing This enabled scene spawning/syncing replication for the scenes "Player" and "Box". For both, spawns are synced, so if you `.instantiate()` them and add them to the scene, that gets done on all other peers automatically as well. -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,8 @@ test() `remotesync func test()` becomes ``` @rpc(any, sync) test() ``` # Using the new multiplayer spawning and syncing -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # Unofficial Godot 4.0 Pre-Alpha Multiplayer Changes Overview **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): -
mhilbrunner revised this gist
Sep 4, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # Unofficial Godot 4.0 Pre-Alpha Multiplayer Changes Overview **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** Ask questions in `#networking` on chat.godotengine.org Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): - https://godotengine.org/article/multiplayer-changes-godot-4-0-report-1 -
mhilbrunner created this gist
Sep 4, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ # Unofficial Godot 4.0 Pre-Alpha Multiplayer Changes Overview **Note: Everything may still change, if you need something stable and documented to depend on, use Godot 3.x/stable.** Relevant Pull Requests (look at [all](https://github.com/godotengine/godot/pulls?q=is%3Apr+label%3Atopic%3Anetwork+is%3Aclosed)): - https://godotengine.org/article/multiplayer-changes-godot-4-0-report-1 - Spawn sync: https://github.com/godotengine/godot/pull/51097 and https://github.com/godotengine/godot/pull/51534 - State sync: https://github.com/godotengine/godot/pull/51788 - Renames: https://github.com/godotengine/godot/pull/51481 and https://github.com/godotengine/godot/pull/50398 - `close_connection()` is silent now: https://github.com/godotengine/godot/pull/52342 - By default, all peers can now call RPC methods, whereas previously it was only `master`: https://github.com/godotengine/godot/pull/51301 - Channels are now supported in MultiplayerPeer: https://github.com/godotengine/godot/pull/51005 - Mesh networking and lowlevel wrappers for ENet: https://github.com/godotengine/godot/pull/50710 - RSETs got removed: https://github.com/godotengine/godot/pull/49221 - Tons of fixes and improvements :) # Setup peer ``` # Create peer var peer = ENetMultiplayerPeer.new() # Connect some signals if you want them peer.peer_connected.connect(_peer_connected) peer.peer_disconnected.connect(_peer_disconnected) peer.connection_failed.connect(_connection_failed) peer.connection_succeeded.connect(_connection_succeeded) # peer.create_server(SERVER_PORT) peer.create_client(SERVER_IP, SERVER_PORT) # Assign peer to multiplayer API # Multiplayer API now has most relevant functions, have a look at get_tree().multiplayer get_tree().multiplayer.network_peer = peer ``` # RPCs (RSETs are gone, just use RPCs now) `remote func test()` becomes ``` @rpc test() ``` `remotesync func test()` becomes ``` @rpc(any, sync) test() ``` # Using the new multiplayer spawning and syncing This enabled scene spawning/syncing replication for the scenes "Player" and "Box". For both, spawns are synced, so if you `.instantiate()` them and add them to the scene, that gets done on all other peers automatically as well. For "Player", `position` is kept synced as well, so if you move, `position` gets updated on peers. For real use, you want to use a custom RPC for movement (to be able to interpolate the position and smooth updates). But this is useful to keep less important things synchronized. ``` func _setup_replication(): _replication_setup(Player, ["position"], true) _replication_setup(Box, ["position"]) func _replication_setup(scene : PackedScene, params : Array, sync : bool = false): # Scenes are identified using the new resource UIDs var id = ResourceLoader.get_resource_uid(scene.resource_path) # Enabled spawn syncing multiplayer.replicator.spawn_config( id, MultiplayerReplicator.REPLICATION_MODE_SERVER, params ) if sync: # Enable property syncing multiplayer.replicator.sync_config(id, 16, params) ``` # Other changes - `Node.set_network_master()` is now `Node.set_network_authority()`