From 255d45d9caa8bf52625255c0176fb90998a96c75 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 25 Dec 2023 20:47:45 +0100 Subject: [PATCH] Fix the network synchronizer demo for pandemonium. --- networking/network_synchronizer/MainScene.gd | 10 ++++++-- .../network_synchronizer/MainScene.tscn | 4 ++-- .../network_synchronizer/default_env.tres | 2 +- .../network_synchronizer/project.pandemonium | 24 ++++--------------- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/networking/network_synchronizer/MainScene.gd b/networking/network_synchronizer/MainScene.gd index 1114853..658dce6 100644 --- a/networking/network_synchronizer/MainScene.gd +++ b/networking/network_synchronizer/MainScene.gd @@ -89,7 +89,7 @@ func _on_client_disconnected(peer_id): # --------------------------------------------------------------------------------- Remote functions -remote func _spawn_new_player(player_id, peer_id): +func _spawn_new_player(player_id, peer_id): print("Spawn player id: ", player_id, ", Peer_id: ", peer_id) print("While my peer id is: ", get_tree().multiplayer.network_peer.get_unique_id()) @@ -100,7 +100,13 @@ remote func _spawn_new_player(player_id, peer_id): character.set_color(COLORS_LIST[player_id]) -remote func _remove_player(player_id): +func _remove_player(player_id): var player_node = get_tree().get_current_scene().get_node("player_" + str(player_id)) if player_node != null: player_node.queue_free() + + +func _ready() -> void: + rpc_config(@"_spawn_new_player", MultiplayerAPI.RPC_MODE_REMOTE) + rpc_config(@"_remove_player", MultiplayerAPI.RPC_MODE_REMOTE) + diff --git a/networking/network_synchronizer/MainScene.tscn b/networking/network_synchronizer/MainScene.tscn index c52aeb6..4c75532 100644 --- a/networking/network_synchronizer/MainScene.tscn +++ b/networking/network_synchronizer/MainScene.tscn @@ -5,7 +5,7 @@ [sub_resource type="ProceduralSky" id=1] -[sub_resource type="Environment" id=2] +[sub_resource type="Environment3D" id=2] background_mode = 2 background_sky = SubResource( 1 ) @@ -27,7 +27,7 @@ radius = 0.25 [node name="Node" type="Node"] script = ExtResource( 1 ) -[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +[node name="WorldEnvironment3D" type="WorldEnvironment3D" parent="."] environment = SubResource( 2 ) [node name="DirectionalLight" type="DirectionalLight" parent="."] diff --git a/networking/network_synchronizer/default_env.tres b/networking/network_synchronizer/default_env.tres index 20207a4..4f08e8f 100644 --- a/networking/network_synchronizer/default_env.tres +++ b/networking/network_synchronizer/default_env.tres @@ -1,4 +1,4 @@ -[gd_resource type="Environment" load_steps=2 format=2] +[gd_resource type="Environment3D" load_steps=2 format=2] [sub_resource type="ProceduralSky" id=1] diff --git a/networking/network_synchronizer/project.pandemonium b/networking/network_synchronizer/project.pandemonium index 2b10b99..d4e2f4d 100644 --- a/networking/network_synchronizer/project.pandemonium +++ b/networking/network_synchronizer/project.pandemonium @@ -8,16 +8,6 @@ config_version=4 -_global_script_classes=[ { -"base": "SpringArm3D", -"class": @"PlayerCamera", -"language": @"GDScript", -"path": "res://player_camera.gd" -} ] -_global_script_class_icons={ -@"PlayerCamera": "" -} - [NetworkSynchronizer] debug_doll_speedup=true @@ -53,27 +43,27 @@ singletons=[ ] forward={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"action_match_force_exact":false,"script":null) ] } backward={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"action_match_force_exact":false,"script":null) ] } left={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":65,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":65,"unicode":0,"echo":false,"action_match_force_exact":false,"script":null) ] } right={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":68,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":68,"unicode":0,"echo":false,"action_match_force_exact":false,"script":null) ] } jump={ "deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null) +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"action_match_force_exact":false,"script":null) ] } @@ -86,7 +76,3 @@ jump={ common/physics_jitter_fix=0.0 common/enable_pause_aware_picking=true - -[rendering] - -environment/default_environment="res://default_env.tres"