Networking
This commit is contained in:
@@ -6,15 +6,15 @@
|
||||
[ext_resource type="Shader" path="res://assets/shader/crosshair.gdshader" id="3_3vnqi"]
|
||||
[ext_resource type="Script" path="res://entities/PlayerSync.gd" id="5_828co"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_8iawe"]
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_6d8kk"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4aqh7"]
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ikq67"]
|
||||
albedo_texture = ExtResource("2_mxb5i")
|
||||
uv1_scale = Vector3(3, 2, 1)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_dh7aw"]
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_4e7dm"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_giw1l"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_08bwh"]
|
||||
shader = ExtResource("3_3vnqi")
|
||||
shader_parameter/center_enabled = null
|
||||
shader_parameter/legs_enabled = null
|
||||
@@ -29,36 +29,36 @@ shader_parameter/len = null
|
||||
shader_parameter/spacing = null
|
||||
shader_parameter/spread = null
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_86371"]
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rfdcv"]
|
||||
properties/0/path = NodePath("Body/Head:rotation")
|
||||
properties/0/spawn = true
|
||||
properties/0/sync = true
|
||||
properties/1/path = NodePath("Body:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/sync = true
|
||||
properties/2/path = NodePath("Networking:sync_velocity")
|
||||
properties/2/spawn = true
|
||||
properties/2/path = NodePath("Networking:player_state")
|
||||
properties/2/spawn = false
|
||||
properties/2/sync = true
|
||||
properties/3/path = NodePath("Networking:sync_position")
|
||||
properties/3/spawn = true
|
||||
properties/3/sync = true
|
||||
properties/4/path = NodePath("Networking:processed_position")
|
||||
properties/3/sync = false
|
||||
properties/4/path = NodePath("Networking:sync_velocity")
|
||||
properties/4/spawn = true
|
||||
properties/4/sync = true
|
||||
properties/4/sync = false
|
||||
|
||||
[node name="PlayerQ3" type="CharacterBody3D"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CylinderShape3D_8iawe")
|
||||
shape = SubResource("CylinderShape3D_6d8kk")
|
||||
|
||||
[node name="Body" type="Node3D" parent="."]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Body"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
material_override = SubResource("StandardMaterial3D_4aqh7")
|
||||
mesh = SubResource("CylinderMesh_dh7aw")
|
||||
material_override = SubResource("StandardMaterial3D_ikq67")
|
||||
mesh = SubResource("CylinderMesh_4e7dm")
|
||||
skeleton = NodePath("../../CollisionShape3D")
|
||||
|
||||
[node name="Head" type="Node3D" parent="Body"]
|
||||
@@ -68,12 +68,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.75, 0)
|
||||
script = ExtResource("2_dl1i1")
|
||||
|
||||
[node name="Crosshair" type="ColorRect" parent="Body/Head/Hand"]
|
||||
material = SubResource("ShaderMaterial_giw1l")
|
||||
material = SubResource("ShaderMaterial_08bwh")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="Body/Head"]
|
||||
cull_mask = 1048573
|
||||
@@ -95,4 +97,4 @@ script = ExtResource("5_828co")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="Networking"]
|
||||
root_path = NodePath("../..")
|
||||
replication_config = SubResource("SceneReplicationConfig_86371")
|
||||
replication_config = SubResource("SceneReplicationConfig_rfdcv")
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
extends Node
|
||||
|
||||
###SYNC PLAYER###
|
||||
const PLAYER_STATE_SIZE = 13
|
||||
var player_state:
|
||||
get:
|
||||
var buf = PackedByteArray()
|
||||
buf.resize(PLAYER_STATE_SIZE)
|
||||
buf.encode_half(0, sync_position.x)
|
||||
buf.encode_half(2, sync_position.y)
|
||||
buf.encode_half(4, sync_position.z)
|
||||
buf.encode_half(6, sync_velocity.x)
|
||||
buf.encode_half(8, sync_velocity.y)
|
||||
buf.encode_half(10, sync_velocity.z)
|
||||
return buf
|
||||
set(value):
|
||||
assert(typeof(value) == TYPE_PACKED_BYTE_ARRAY and value.size() == PLAYER_STATE_SIZE,
|
||||
"Invalid `player_state` array type or size (must be TYPE_PACKED_BYTE_ARRAY of size 11).")
|
||||
sync_position = Vector3(value.decode_half(0), value.decode_half(2), value.decode_half(4))
|
||||
sync_velocity = Vector3(value.decode_half(6), value.decode_half(8), value.decode_half(10))
|
||||
|
||||
var sync_position : Vector3:
|
||||
set(value):
|
||||
sync_position = value
|
||||
@@ -8,3 +27,5 @@ var sync_velocity : Vector3
|
||||
var sync_is_jumping : bool
|
||||
|
||||
var processed_position : bool
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user