From 32549e36c655fd557923dea4fd45f97f1539103f Mon Sep 17 00:00:00 2001 From: MitchMakesThings Date: Sun, 5 Jun 2022 12:56:09 +0100 Subject: [PATCH] Updating networking example to Godot 4 Alpha 9. There are some typo's in configuration settings, so I expect this to break in Alpha 10 :( --- .../Multiplayer/Characters/Aliens/Player.tscn | 20 ++++++++----------- .../Multiplayer/Items/blue_button.tscn | 5 ++--- .../Multiplayer/System/game_state.tscn | 5 ++--- .../Explained/Multiplayer/System/main.gd | 2 +- .../Explained/Multiplayer/System/main.tscn | 5 ++--- Networking/Explained/run-client.bat | 2 +- Networking/Explained/run-server.bat | 2 +- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Networking/Explained/Multiplayer/Characters/Aliens/Player.tscn b/Networking/Explained/Multiplayer/Characters/Aliens/Player.tscn index 60b93a9..c244127 100644 --- a/Networking/Explained/Multiplayer/Characters/Aliens/Player.tscn +++ b/Networking/Explained/Multiplayer/Characters/Aliens/Player.tscn @@ -24,15 +24,15 @@ colors = PackedColorArray(0, 0.278431, 0.486275, 1, 0, 0.576471, 1, 1) [sub_resource type="GradientTexture1D" id="GradientTexture1D_cduq7"] gradient = SubResource( "Gradient_168qg" ) -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_t66em"] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_34p3j"] properties/0/path = NodePath(":sync_position") properties/0/spawn = true properties/0/sync = true -properties/1/path = NodePath(":sync_is_jumping") -properties/1/spawn = false +properties/1/path = NodePath(":sync_velocity") +properties/1/spawn = true properties/1/sync = true -properties/2/path = NodePath(":sync_velocity") -properties/2/spawn = false +properties/2/path = NodePath(":sync_is_jumping") +properties/2/spawn = true properties/2/sync = true [node name="Player" type="CharacterBody2D"] @@ -67,22 +67,18 @@ offset_left = -56.0 offset_top = -29.0 offset_right = -16.0 offset_bottom = 11.0 -__meta__ = { -"_edit_use_anchors_": false -} [node name="TextureProgressBar" type="TextureProgressBar" parent="UI"] offset_right = 15.0 offset_bottom = 66.0 value = 100.0 -texture_under = SubResource( "GradientTexture1D_lsl6q" ) -texture_progress = SubResource( "GradientTexture1D_cduq7" ) fill_mode = 3 nine_patch_stretch = true +texture_under = SubResource( "GradientTexture1D_lsl6q" ) +texture_progress = SubResource( "GradientTexture1D_cduq7" ) [node name="Networking" type="Node" parent="."] script = ExtResource( "4_h5uv8" ) [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="Networking"] -root_path = NodePath("..") -resource = SubResource( "SceneReplicationConfig_t66em" ) +congiruation = SubResource( "SceneReplicationConfig_34p3j" ) diff --git a/Networking/Explained/Multiplayer/Items/blue_button.tscn b/Networking/Explained/Multiplayer/Items/blue_button.tscn index 1e0a27b..285d91c 100644 --- a/Networking/Explained/Multiplayer/Items/blue_button.tscn +++ b/Networking/Explained/Multiplayer/Items/blue_button.tscn @@ -7,7 +7,7 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_8apkt"] size = Vector2(64, 61) -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ja6x7"] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ntf3m"] properties/0/path = NodePath(":isPressed") properties/0/spawn = true properties/0/sync = true @@ -27,8 +27,7 @@ position = Vector2(0, -29) shape = SubResource( "RectangleShape2D_8apkt" ) [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] -root_path = NodePath("..") replication_interval = 0.5 -resource = SubResource( "SceneReplicationConfig_ja6x7" ) +congiruation = SubResource( "SceneReplicationConfig_ntf3m" ) [connection signal="body_entered" from="." to="." method="_on_blue_button_body_entered"] diff --git a/Networking/Explained/Multiplayer/System/game_state.tscn b/Networking/Explained/Multiplayer/System/game_state.tscn index 3b25b15..e6b0819 100644 --- a/Networking/Explained/Multiplayer/System/game_state.tscn +++ b/Networking/Explained/Multiplayer/System/game_state.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://System/game_state.gd" id="1_g0bil"] -[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_4l240"] +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_bylt0"] properties/0/path = NodePath(":button_press_count") properties/0/spawn = true properties/0/sync = true @@ -11,6 +11,5 @@ properties/0/sync = true script = ExtResource( "1_g0bil" ) [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] -root_path = NodePath("..") replication_interval = 1.0 -resource = SubResource( "SceneReplicationConfig_4l240" ) +congiruation = SubResource( "SceneReplicationConfig_bylt0" ) diff --git a/Networking/Explained/Multiplayer/System/main.gd b/Networking/Explained/Multiplayer/System/main.gd index 2ad5125..40ad000 100644 --- a/Networking/Explained/Multiplayer/System/main.gd +++ b/Networking/Explained/Multiplayer/System/main.gd @@ -23,7 +23,7 @@ func start_network(server: bool) -> void: peer.create_server(4242) print('server listening on localhost 4242') else: - peer.create_client("networking-explained.mitchmakesthings.online", 4242) + peer.create_client("localhost", 4242) multiplayer.set_multiplayer_peer(peer) diff --git a/Networking/Explained/Multiplayer/System/main.tscn b/Networking/Explained/Multiplayer/System/main.tscn index e531b94..cb3d4fb 100644 --- a/Networking/Explained/Multiplayer/System/main.tscn +++ b/Networking/Explained/Multiplayer/System/main.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=5 format=3 uid="uid://cruxxhpoyibub"] +[gd_scene load_steps=4 format=3 uid="uid://cruxxhpoyibub"] [ext_resource type="Script" path="res://System/main.gd" id="1_n31dg"] -[ext_resource type="PackedScene" uid="uid://scjoku8kmkqj" path="res://Characters/Aliens/Player.tscn" id="2_tebs4"] [ext_resource type="PackedScene" uid="uid://dhvi1o1ili7f" path="res://Maps/TestMap.tscn" id="3_uwrpn"] [ext_resource type="Script" path="res://System/UI.gd" id="4_kv3lk"] @@ -14,7 +13,7 @@ script = ExtResource( "1_n31dg" ) position = Vector2(325, 0) [node name="PlayerSpawner" type="MultiplayerSpawner" parent="."] -replication = [ExtResource( "2_tebs4" )] +_spawnable_scenes = PackedStringArray("res://Characters/Aliens/Player.tscn") spawn_path = NodePath("../Players") auto_spawn = true diff --git a/Networking/Explained/run-client.bat b/Networking/Explained/run-client.bat index 27df3e7..dfd4af2 100644 --- a/Networking/Explained/run-client.bat +++ b/Networking/Explained/run-client.bat @@ -1 +1 @@ -"C:\Users\Mitch\Documents\godot\Alpha3\Godot_v4.0-alpha3_win64.exe" --path .\Multiplayer\ \ No newline at end of file +"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha9_win64.exe\Godot_v4.0-alpha9_win64.exe" --path .\Multiplayer\ --client \ No newline at end of file diff --git a/Networking/Explained/run-server.bat b/Networking/Explained/run-server.bat index ecbf04b..6dab36f 100644 --- a/Networking/Explained/run-server.bat +++ b/Networking/Explained/run-server.bat @@ -1 +1 @@ -"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha4_win64.exe\Godot_v4.0-alpha4_win64.exe" --path .\Multiplayer\ --server \ No newline at end of file +"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha9_win64.exe\Godot_v4.0-alpha9_win64.exe" --path .\Multiplayer\ --server \ No newline at end of file