diff --git a/kristofers/game/code/player.gd b/kristofers/game/code/player.gd index 0397088..c3d3002 100644 --- a/kristofers/game/code/player.gd +++ b/kristofers/game/code/player.gd @@ -33,9 +33,10 @@ func _process(delta: float) -> void: func _physics_process(delta): - if is_network_master(): - mode_switch(delta) - screen_wrap() + if get_tree().has_network_peer(): + if is_network_master(): + mode_switch(delta) + screen_wrap() func mode_switch(delta): @@ -117,10 +118,11 @@ func _network_peer_connected(id) -> void: func _on_network_tick_rate_timeout(): - if is_network_master(): - rset_unreliable("puppet_position", global_position) - rset_unreliable("puppet_velocity", velocity) - rset_unreliable("puppet_rotation", rotation_degrees) + if get_tree().has_network_peer(): + if is_network_master(): + rset_unreliable("puppet_position", global_position) + rset_unreliable("puppet_velocity", velocity) + rset_unreliable("puppet_rotation", rotation_degrees) sync func update_position(pos): diff --git a/kristofers/game/code/server/network.gd b/kristofers/game/code/server/network.gd index 2dd37bf..6d432b5 100644 --- a/kristofers/game/code/server/network.gd +++ b/kristofers/game/code/server/network.gd @@ -78,7 +78,7 @@ func _client_connection_timeout(): print("Client has been timed out") reset_network_connection() - var connection_timeout_prompt = Global.instance_node(load("res://Simple_prompt.tscn"), get_tree().current_scene) + var connection_timeout_prompt = Global.instance_node(load("res://scenes/simple_prompt.tscn"), get_tree().current_scene) connection_timeout_prompt.set_text("Connection timed out") @@ -89,7 +89,7 @@ func _connection_failed(): reset_network_connection() if Global.ui != null: - var prompt = Global.instance_node(load("res://Simple_prompt.tscn"), Global.ui) + var prompt = Global.instance_node(load("res://scenes/simple_prompt.tscn"), Global.ui) prompt.set_text("Connection failed") diff --git a/kristofers/game/scenes/game.tscn b/kristofers/game/scenes/game.tscn index bc23185..4a9dd43 100644 --- a/kristofers/game/scenes/game.tscn +++ b/kristofers/game/scenes/game.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://scenes/floor.tscn" type="PackedScene" id=1] [ext_resource path="res://code/game.gd" type="Script" id=2] +[ext_resource path="res://code/UI.gd" type="Script" id=3] [node name="game" type="Node2D"] script = ExtResource( 2 ) @@ -23,3 +24,6 @@ position = Vector2( 512, 270 ) [node name="4" type="Position2D" parent="spawn_locations"] position = Vector2( 1408, 270 ) + +[node name="UI" type="CanvasLayer" parent="."] +script = ExtResource( 3 )