Skip to content

Commit

Permalink
Updating networking explained to Alpha 11
Browse files Browse the repository at this point in the history
This fixes a crash on startup caused by the new Alpha ignoring old replication configs.
Also flipped the camera zoom to match the new camera zoom direction (godotengine/godot#57392 - added in Alpha 5!)
Resolves #3
  • Loading branch information
MitchMakesThings committed Jul 6, 2022
1 parent 32549e3 commit e323c5c
Show file tree
Hide file tree
Showing 12 changed files with 370 additions and 41 deletions.
329 changes: 329 additions & 0 deletions 0001-Updating-networking-explained-to-Alpha-11.patch

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Networking/Explained/Multiplayer/Characters/Aliens/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class_name Player
const SPEED = 300.0
const JUMP_FORCE = -400.0
const MAX_JUMP_FUEL = 100.0
const CAMERA_MAX_ZOOM := Vector2(2.5, 2.5)
const CAMERA_MAX_ZOOM := Vector2(0.5, 0.5)

# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
Expand Down Expand Up @@ -56,13 +56,13 @@ func _physics_process(delta):
jump_fuel -= 1
is_jumping = true

if $Camera2D.zoom.length() < CAMERA_MAX_ZOOM.length():
if $Camera2D.zoom.length() > CAMERA_MAX_ZOOM.length():
$Camera2D.zoom = $Camera2D.zoom.lerp(CAMERA_MAX_ZOOM, 0.01)
else:
is_jumping = false
$JetpackParticles.emitting = false
var zoom = $Camera2D.zoom.length()
if zoom > 1:
if zoom < 1:
$Camera2D.zoom = $Camera2D.zoom.lerp(Vector2(1, 1), zoom * 0.005)

if is_on_floor():
Expand Down
24 changes: 12 additions & 12 deletions Networking/Explained/Multiplayer/Characters/Aliens/Player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ height = 100.0
colors = PackedColorArray(0, 0.164706, 0.290196, 1, 0, 0.258824, 0.454902, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_lsl6q"]
gradient = SubResource( "Gradient_din52" )
gradient = SubResource("Gradient_din52")

[sub_resource type="Gradient" id="Gradient_168qg"]
colors = PackedColorArray(0, 0.278431, 0.486275, 1, 0, 0.576471, 1, 1)

[sub_resource type="GradientTexture1D" id="GradientTexture1D_cduq7"]
gradient = SubResource( "Gradient_168qg" )
gradient = SubResource("Gradient_168qg")

[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_34p3j"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_xoauy"]
properties/0/path = NodePath(":sync_position")
properties/0/spawn = true
properties/0/sync = true
Expand All @@ -37,27 +37,27 @@ properties/2/sync = true

[node name="Player" type="CharacterBody2D"]
collision_layer = 3
script = ExtResource( "1_ytcn0" )
script = ExtResource("1_ytcn0")

[node name="JetpackParticles" type="CPUParticles2D" parent="."]
position = Vector2(-4, 47)
emitting = false
amount = 32
local_coords = false
draw_order = 1
texture = ExtResource( "2_bvf2j" )
texture = ExtResource("2_bvf2j")
emission_shape = 1
emission_sphere_radius = 12.43
gravity = Vector2(0, 98)
scale_amount_min = 0.5
color_ramp = SubResource( "Gradient_oqb3v" )
color_ramp = SubResource("Gradient_oqb3v")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
frames = ExtResource( "1_bgwyd" )
frames = ExtResource("1_bgwyd")

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
shape = SubResource( "CapsuleShape2D_b0aad" )
shape = SubResource("CapsuleShape2D_b0aad")

[node name="Camera2D" type="Camera2D" parent="."]
smoothing_enabled = true
Expand All @@ -74,11 +74,11 @@ offset_bottom = 66.0
value = 100.0
fill_mode = 3
nine_patch_stretch = true
texture_under = SubResource( "GradientTexture1D_lsl6q" )
texture_progress = SubResource( "GradientTexture1D_cduq7" )
texture_under = SubResource("GradientTexture1D_lsl6q")
texture_progress = SubResource("GradientTexture1D_cduq7")

[node name="Networking" type="Node" parent="."]
script = ExtResource( "4_h5uv8" )
script = ExtResource("4_h5uv8")

[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="Networking"]
congiruation = SubResource( "SceneReplicationConfig_34p3j" )
replication_config = SubResource("SceneReplicationConfig_xoauy")
14 changes: 7 additions & 7 deletions Networking/Explained/Multiplayer/Items/blue_button.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8apkt"]
size = Vector2(64, 61)

[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ntf3m"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_a2ivw"]
properties/0/path = NodePath(":isPressed")
properties/0/spawn = true
properties/0/sync = true

[node name="BlueButton" type="Area2D"]
collision_mask = 2
script = ExtResource( "1_35n0c" )
pressed_texture = ExtResource( "2_kyogj" )
default_texture = ExtResource( "2_3l0fu" )
script = ExtResource("1_35n0c")
pressed_texture = ExtResource("2_kyogj")
default_texture = ExtResource("2_3l0fu")

[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(0, -36)
texture = ExtResource( "2_3l0fu" )
texture = ExtResource("2_3l0fu")

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -29)
shape = SubResource( "RectangleShape2D_8apkt" )
shape = SubResource("RectangleShape2D_8apkt")

[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_interval = 0.5
congiruation = SubResource( "SceneReplicationConfig_ntf3m" )
replication_config = SubResource("SceneReplicationConfig_a2ivw")

[connection signal="body_entered" from="." to="." method="_on_blue_button_body_entered"]
6 changes: 3 additions & 3 deletions Networking/Explained/Multiplayer/Maps/TestMap.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[node name="TestMap" type="TileMap"]
position = Vector2(317, 5)
tile_set = ExtResource( "1_kkrey" )
tile_set = ExtResource("1_kkrey")
format = 2
layer_0/tile_data = PackedInt32Array(-1245212, 65537, 5, -1179676, 65537, 5, -1114140, 65537, 5, -1048604, 65537, 5, -983068, 65537, 5, -1245211, 65537, 5, -983067, 65537, 5, -917531, 65537, 5, -1310746, 65537, 5, -851994, 65537, 5, -786458, 65537, 5, -1310745, 65537, 5, -720921, 65537, 5, -1310744, 65537, 5, -720920, 65537, 5, -655384, 65537, 5, -1310743, 65537, 5, -589847, 65537, 5, -1310742, 65537, 5, -589846, 65537, 5, -524310, 65537, 5, -1310741, 65537, 5, -524309, 65537, 5, -458773, 65537, 5, -1310740, 65537, 5, -458772, 65537, 5, -393236, 65537, 5, -1310739, 65537, 5, -393235, 65537, 5, -327699, 65537, 5, -1310738, 65537, 5, -327698, 65537, 5, -262162, 65537, 5, -196626, 65537, 5, -131090, 65537, 5, -65554, 65537, 5, -18, 65537, 5, 65518, 65537, 5, -1310737, 65537, 5, 65519, 65537, 5, 131055, 65537, 5, -1310736, 65537, 5, 131056, 65537, 5, 196592, 65537, 5, 262128, 65537, 5, 327664, 65537, 5, -1245199, 65537, 5, 327665, 65537, 5, 393201, 65537, 5, 458737, 65537, 5, 524273, 65537, 5, 589809, 65537, 5, 655345, 65537, 5, -1245198, 65537, 5, 655346, 65537, 5, -1179661, 65537, 5, 655347, 65537, 5, -1179660, 65537, 5, -1114124, 65537, 5, 655348, 65537, 5, -1048587, 65537, 5, -983051, 65537, 5, -917515, 65537, 5, -851979, 65537, 5, 655349, 65537, 5, -786442, 65537, 5, -720906, 65537, 5, -655370, 65537, 5, 589814, 65537, 5, 655350, 65537, 5, -655369, 65537, 5, 458743, 65537, 5, 524279, 65537, 5, 589815, 65537, 5, -720904, 65537, 5, 393208, 65537, 5, 458744, 65537, 5, -720903, 65537, 5, 393209, 65537, 5, -720902, 65537, 5, -327686, 65537, 5, 393210, 65537, 5, -851973, 65537, 5, -786437, 65537, 5, -327685, 65537, 5, 393211, 65537, 5, -1310724, 65537, 5, -1245188, 65537, 5, -1179652, 65537, 5, -1114116, 65537, 5, -1048580, 65537, 5, -983044, 65537, 5, -917508, 65537, 5, -327684, 65537, 5, 393212, 65537, 5, -1507331, 65537, 5, -1441795, 65537, 5, -1376259, 65537, 5, -1310723, 65537, 5, -327683, 65537, 5, 393213, 65537, 6, -1638402, 65537, 5, -1572866, 65537, 5, -1507330, 65537, 5, -1310722, 65537, 5, -327682, 65537, 5, 393214, 65537, 6, 458750, 262145, 9, -1638401, 65537, 5, -1310721, 65537, 5, -327681, 65537, 5, 393215, 65537, 6, 458751, 262145, 9, -1703936, 65537, 5, -1376256, 65537, 5, -393216, 65537, 5, 327680, 65537, 6, 393216, 262145, 9, -1638399, 65537, 5, -1310719, 65537, 5, -393215, 65537, 5, 327681, 65537, 6, 393217, 262145, 9, -1638398, 65537, 5, -1310718, 65537, 5, -393214, 65537, 5, 131074, 65537, 6, 327682, 65537, 6, 393218, 262145, 9, -1638397, 65537, 5, -1310717, 65537, 5, -393213, 65537, 5, 131075, 65537, 6, 327683, 65537, 6, 393219, 262145, 9, 458755, 262145, 9, -1638396, 65537, 5, -1310716, 65537, 5, 131076, 65537, 6, 327684, 65537, 6, 458756, 262145, 9, -1703931, 65537, 5, -1310715, 65537, 5, 131077, 65537, 6, 327685, 65537, 6, 458757, 262145, 9, -1703930, 65537, 5, -1310714, 65537, 5, 131078, 65537, 6, 327686, 65537, 6, 458758, 262145, 9, -1703929, 65537, 5, -1310713, 65537, 5, 131079, 65537, 5, 327687, 65537, 6, 458759, 262145, 9, -1703928, 65537, 5, -1310712, 65537, 5, -1245176, 65537, 5, -1179640, 65537, 5, -1114104, 65537, 5, 327688, 65537, 6, 458760, 262145, 9, -1769463, 65537, 5, 327689, 65537, 6, 458761, 262145, 9, -1769462, 65537, 5, 327690, 65537, 6, 458762, 262145, 9, -1769461, 65537, 5, 327691, 65537, 6, 458763, 262145, 9, -1834996, 65537, 5, 131084, 65537, 6, 327692, 65537, 6, -1834995, 65537, 5, -327667, 65537, 5, 327693, 65537, 5, -1900530, 65537, 5, -327666, 65537, 5, 327694, 65537, 5, -1900529, 65537, 5, -327665, 65537, 5, 327695, 65537, 5, -1966064, 65537, 5, -327664, 65537, 5, 327696, 65537, 5, -1966063, 65537, 5, -327663, 65537, 5, 327697, 65537, 5, -1966062, 65537, 5, -327662, 65537, 5, 327698, 65537, 5, -2031597, 65537, 5, -327661, 65537, 5, 19, 65537, 5, 262163, 65537, 5, 327699, 65537, 5, -2031596, 65537, 5, -327660, 65537, 5, 20, 65537, 5, 65556, 65537, 5, 131092, 65537, 5, 196628, 65537, 5, 262164, 65537, 5, -2097131, 65537, 5, -327659, 65537, 5, 21, 65537, 5, -2097130, 65537, 5, -327658, 65537, 5, 22, 65537, 5, -2097129, 65537, 5, -393193, 65537, 5, -327657, 65537, 5, 23, 65537, 5, -2097128, 65537, 5, -393192, 65537, 5, 24, 65537, 5, -2097127, 65537, 5, -524263, 65537, 5, -458727, 65537, 5, 25, 65537, 5, -2097126, 65537, 5, -589798, 65537, 5, -524262, 65537, 5, 26, 65537, 5, -2162661, 65537, 5, -655333, 65537, 5, -589797, 65537, 5, 27, 65537, 5, -2162660, 65537, 5, -720868, 65537, 5, -655332, 65537, 5, 28, 65537, 5, -2162659, 65537, 5, -720867, 65537, 5, 65565, 65537, 5, -2162658, 65537, 5, -1245154, 65537, 5, -1179618, 65537, 5, -720866, 65537, 5, 65566, 65537, 5, -2097121, 65537, 5, -1310689, 65537, 5, -1245153, 65537, 5, 65567, 65537, 5, 131103, 65537, 5, -2097120, 65537, 5, -1376224, 65537, 5, -1310688, 65537, 5, 131104, 65537, 5, -2031583, 65537, 5, -1441759, 65537, 5, 131105, 65537, 5, 196641, 65537, 5, -2031582, 65537, 5, -1441758, 65537, 5, 196642, 65537, 5, 262178, 65537, 5, -2031581, 65537, 5, -1441757, 65537, 5, 262179, 65537, 5, -2031580, 65537, 5, -1441756, 65537, 5, 262180, 65537, 5, -1966043, 65537, 5, -1441755, 65537, 5, 262181, 65537, 5, -1900506, 65537, 5, -1441754, 65537, 5, 262182, 65537, 5, -1834969, 65537, 5, -1441753, 65537, 5, 262183, 65537, 5, -1769432, 65537, 5, -1703896, 65537, 5, -1441752, 65537, 5, 196648, 65537, 5, 262184, 65537, 5, -1638359, 65537, 5, -1572823, 65537, 5, -1507287, 65537, 5, -1441751, 65537, 5, 131113, 65537, 5, 196649, 65537, 5, -1441750, 65537, 5, -65494, 65537, 5, 42, 65537, 5, 65578, 65537, 5, -1441749, 65537, 5, -1376213, 65537, 5, -851925, 65537, 5, -786389, 65537, 5, -720853, 65537, 5, -655317, 65537, 5, -589781, 65537, 5, -524245, 65537, 5, -458709, 65537, 5, -393173, 65537, 5, -327637, 65537, 5, -262101, 65537, 5, -196565, 65537, 5, -131029, 65537, 5, -1376212, 65537, 5, -982996, 65537, 5, -917460, 65537, 5, -851924, 65537, 5, -1310675, 65537, 5, -1245139, 65537, 5, -1179603, 65537, 5, -1114067, 65537, 5, -1048531, 65537, 5)

Expand All @@ -16,8 +16,8 @@ zoom = Vector2(5, 5)

[node name="Buttons" type="Node2D" parent="."]

[node name="BlueButton" parent="Buttons" instance=ExtResource( "4_dd5ct" )]
[node name="BlueButton" parent="Buttons" instance=ExtResource("4_dd5ct")]
position = Vector2(315, 351)

[node name="BlueButton2" parent="Buttons" instance=ExtResource( "4_dd5ct" )]
[node name="BlueButton2" parent="Buttons" instance=ExtResource("4_dd5ct")]
position = Vector2(2, -1469)
4 changes: 2 additions & 2 deletions Networking/Explained/Multiplayer/Maps/Tileset.tres
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ext_resource type="Texture2D" uid="uid://cday0n3k0g4ew" path="res://Maps/tiles_spritesheet.png" id="1_c0bnl"]

[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ju6b1"]
texture = ExtResource( "1_c0bnl" )
texture = ExtResource("1_c0bnl")
separation = Vector2i(2, 2)
texture_region_size = Vector2i(70, 70)
use_texture_padding = false
Expand Down Expand Up @@ -490,4 +490,4 @@ use_texture_padding = false
[resource]
tile_size = Vector2i(70, 70)
physics_layer_0/collision_layer = 1
sources/1 = SubResource( "TileSetAtlasSource_ju6b1" )
sources/1 = SubResource("TileSetAtlasSource_ju6b1")
6 changes: 3 additions & 3 deletions Networking/Explained/Multiplayer/System/game_state.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

[ext_resource type="Script" path="res://System/game_state.gd" id="1_g0bil"]

[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_bylt0"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_d5pac"]
properties/0/path = NodePath(":button_press_count")
properties/0/spawn = true
properties/0/sync = true

[node name="GameState" type="Node"]
script = ExtResource( "1_g0bil" )
script = ExtResource("1_g0bil")

[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_interval = 1.0
congiruation = SubResource( "SceneReplicationConfig_bylt0" )
replication_config = SubResource("SceneReplicationConfig_d5pac")
6 changes: 3 additions & 3 deletions Networking/Explained/Multiplayer/System/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[ext_resource type="Script" path="res://System/UI.gd" id="4_kv3lk"]

[node name="MainGame" type="Node"]
script = ExtResource( "1_n31dg" )
script = ExtResource("1_n31dg")

[node name="TestMap" parent="." instance=ExtResource( "3_uwrpn" )]
[node name="TestMap" parent="." instance=ExtResource("3_uwrpn")]

[node name="Players" type="Node2D" parent="."]
position = Vector2(325, 0)
Expand All @@ -18,7 +18,7 @@ spawn_path = NodePath("../Players")
auto_spawn = true

[node name="UI" type="CanvasLayer" parent="."]
script = ExtResource( "4_kv3lk" )
script = ExtResource("4_kv3lk")

[node name="CenterContainer" type="CenterContainer" parent="UI"]
anchor_right = 1.0
Expand Down
10 changes: 5 additions & 5 deletions Networking/Explained/Multiplayer/icon.png.import
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[remap]

importer="texture"
type="StreamTexture2D"
type="CompressedTexture2D"
uid="uid://ba17ris64qug7"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]

[params]

Expand All @@ -21,14 +21,14 @@ compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
compress/streamed=false
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/HDR_as_SRGB=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
2 changes: 1 addition & 1 deletion Networking/Explained/Multiplayer/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ _global_script_class_icons={

config/name="Multiplayer"
run/main_scene="res://System/main.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0", "Vulkan Clustered")
config/icon="res://icon.png"

[autoload]

Expand Down
2 changes: 1 addition & 1 deletion Networking/Explained/run-client.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha9_win64.exe\Godot_v4.0-alpha9_win64.exe" --path .\Multiplayer\ --client
"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha11_win64.exe\Godot_v4.0-alpha11_win64.exe" --path .\Multiplayer\ --client
2 changes: 1 addition & 1 deletion Networking/Explained/run-server.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha9_win64.exe\Godot_v4.0-alpha9_win64.exe" --path .\Multiplayer\ --server
"C:\Users\Mitch\Documents\godot\Godot_v4.0-alpha11_win64.exe\Godot_v4.0-alpha11_win64.exe" --path .\Multiplayer\ --server

0 comments on commit e323c5c

Please sign in to comment.