multiplayer: added basic server and client functionality
This commit is contained in:
parent
fced905bae
commit
cf5eb5ae6e
5 changed files with 133 additions and 4 deletions
|
|
@ -16,6 +16,11 @@ var target_velocity = Vector3.ZERO
|
|||
|
||||
var _health = 100
|
||||
|
||||
# Multiplayer
|
||||
|
||||
func _enter_tree():
|
||||
set_multiplayer_authority(str(name).to_int())
|
||||
|
||||
# Player UI
|
||||
|
||||
func resize_ui():
|
||||
|
|
@ -220,8 +225,14 @@ func _ready():
|
|||
get_viewport().size_changed.connect(resize_ui)
|
||||
resize_ui()
|
||||
respawn()
|
||||
|
||||
if is_multiplayer_authority():
|
||||
$CameraGimbal/InnerGimbal/Camera3D.current = true
|
||||
else:
|
||||
$CameraGimbal/InnerGimbal/Camera3D.current = false
|
||||
|
||||
func _physics_process(delta):
|
||||
if not is_multiplayer_authority(): return
|
||||
if health() < 1 or position.y <= -1000:
|
||||
die()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=4 uid="uid://cfceg80unq0pe"]
|
||||
[gd_scene load_steps=9 format=4 uid="uid://cfceg80unq0pe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfflnag3p4gen" path="res://player/player.gd" id="1_onrkg"]
|
||||
[ext_resource type="Script" uid="uid://oi6sint7jkc6" path="res://player/camera_gimbal.gd" id="2_onrkg"]
|
||||
|
|
@ -47,6 +47,32 @@ _surfaces = [{
|
|||
}]
|
||||
shadow_mesh = SubResource("ArrayMesh_e57bw")
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_g1dw6"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath("CameraGimbal:position")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath("CameraGimbal:rotation")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
properties/4/path = NodePath("CameraGimbal/InnerGimbal:position")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
properties/5/path = NodePath("CameraGimbal/InnerGimbal:rotation")
|
||||
properties/5/spawn = true
|
||||
properties/5/replication_mode = 1
|
||||
properties/6/path = NodePath("CameraGimbal/InnerGimbal/Camera3D:position")
|
||||
properties/6/spawn = true
|
||||
properties/6/replication_mode = 1
|
||||
properties/7/path = NodePath("CameraGimbal/InnerGimbal/Camera3D:rotation")
|
||||
properties/7/spawn = true
|
||||
properties/7/replication_mode = 1
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
|
|
@ -100,6 +126,9 @@ text = "Pictures of you"
|
|||
horizontal_alignment = 2
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_g1dw6")
|
||||
|
||||
[connection signal="child_entered_tree" from="Backpack" to="." method="_on_backpack_child_entered_tree"]
|
||||
[connection signal="child_exiting_tree" from="Backpack" to="." method="_on_backpack_child_exiting_tree"]
|
||||
[connection signal="timeout" from="RespawnTimer" to="." method="respawn"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue