WIP: Some updates

This commit is contained in:
Nikolai Rodionov 2025-02-08 19:30:32 +01:00
parent ee8a65a67b
commit 6219397137
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
6 changed files with 42 additions and 33 deletions

View File

@ -18,7 +18,7 @@ func _ready() -> void:
func set_owner_placeholder(owner: Node3D):
owner_placeholder = owner
func die():
func die():
push_warning("TODO: Implement ragdoll kind of dying and respawn character as an object")
queue_free()

View File

@ -2796,7 +2796,7 @@ mesh = SubResource("ArrayMesh_7ywky")
skin = SubResource("Skin_rvj8b")
[node name="HeadAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(0.882565, -0.444116, -0.154401, 0.270521, 0.211033, 0.9393, -0.384574, -0.870762, 0.306393, -6.4511, 7.27766, -150.755)
transform = Transform3D(0.882565, -0.444116, -0.154401, 0.270521, 0.211033, 0.939299, -0.384574, -0.870762, 0.306393, -6.4511, 7.27767, -150.755)
bone_name = "mixamorig_Head"
bone_idx = 5
@ -2813,7 +2813,7 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0,
shape = SubResource("CapsuleShape3D_yrrmu")
[node name="TorsoAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(0.766679, -0.0560176, -0.639582, 0.64197, 0.053182, 0.764883, -0.0088326, -0.997012, 0.0767351, 3.85161, -5.43985, -116.78)
transform = Transform3D(0.766679, -0.0560176, -0.639582, 0.64197, 0.0531821, 0.764883, -0.00883259, -0.997012, 0.0767353, 3.85161, -5.43985, -116.78)
bone_name = "mixamorig_Spine1"
bone_idx = 2
@ -2827,7 +2827,7 @@ body_part = "Torso"
shape = SubResource("CapsuleShape3D_tr87i")
[node name="RightHipAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.807937, -0.161163, -0.566801, -0.581917, 0.0667468, 0.810505, -0.092791, 0.984668, -0.147711, -7.363, -5.25271, -89.2051)
transform = Transform3D(-0.807937, -0.161163, -0.566802, -0.581917, 0.0667467, 0.810505, -0.092791, 0.984668, -0.14771, -7.363, -5.25271, -89.2051)
bone_name = "mixamorig_RightUpLeg"
bone_idx = 60
@ -2843,7 +2843,7 @@ transform = Transform3D(0.997222, -0.0744854, -0.000943551, 0.0744854, 0.997222,
shape = SubResource("CapsuleShape3D_xyxrh")
[node name="RightLegAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.801839, 0.200184, -0.563011, -0.593879, -0.371127, 0.713844, -0.0660485, 0.906748, 0.416469, -13.9061, -2.54282, -49.228)
transform = Transform3D(-0.801839, 0.200184, -0.563011, -0.593879, -0.371127, 0.713844, -0.0660485, 0.906748, 0.416469, -13.9061, -2.54283, -49.228)
bone_name = "mixamorig_RightLeg"
bone_idx = 61
@ -2858,7 +2858,7 @@ body_part = "Right Leg"
shape = SubResource("CapsuleShape3D_h5mrs")
[node name="RightFootAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.588698, -0.731611, -0.343773, -0.806695, 0.504491, 0.307786, -0.0517494, 0.458513, -0.88718, -5.4786, -18.1669, -11.0549)
transform = Transform3D(-0.588698, -0.731611, -0.343773, -0.806695, 0.504491, 0.307786, -0.0517495, 0.458513, -0.88718, -5.4786, -18.1669, -11.0549)
bone_name = "mixamorig_RightFoot"
bone_idx = 62
@ -2873,7 +2873,7 @@ body_part = "Right Foot"
shape = SubResource("BoxShape3D_1pj41")
[node name="RightArmAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(0.374872, -0.587376, 0.717259, 0.864165, 0.501541, -0.0409305, -0.335693, 0.635173, 0.695604, -10.8404, -16.1981, -138.841)
transform = Transform3D(0.374872, -0.587376, 0.717259, 0.864165, 0.501541, -0.0409307, -0.335693, 0.635174, 0.695604, -10.8404, -16.1981, -138.841)
bone_name = "mixamorig_RightArm"
bone_idx = 32
@ -2888,7 +2888,7 @@ body_part = "Right Arm"
shape = SubResource("CapsuleShape3D_56i6t")
[node name="RightForearmAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(0.525953, 0.457071, 0.717259, -0.623016, 0.781137, -0.0409306, -0.578986, -0.425336, 0.695604, -26.9373, -2.45355, -121.435)
transform = Transform3D(0.525953, 0.457071, 0.717259, -0.623016, 0.781137, -0.0409307, -0.578986, -0.425336, 0.695604, -26.9373, -2.45355, -121.435)
bone_name = "mixamorig_RightForeArm"
bone_idx = 33
@ -2903,7 +2903,7 @@ body_part = "Right Forearm"
shape = SubResource("CapsuleShape3D_1sjun")
[node name="RightPalmAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.101872, 0.0272956, 0.994423, -0.100369, 0.994241, -0.0375728, -0.989721, -0.103637, -0.0985452, -14.3155, 19.1172, -133.18)
transform = Transform3D(-0.101872, 0.0272958, 0.994423, -0.100369, 0.994241, -0.0375728, -0.989721, -0.103637, -0.0985454, -14.3155, 19.1172, -133.18)
bone_name = "mixamorig_RightHand"
bone_idx = 34
@ -2919,7 +2919,7 @@ transform = Transform3D(1, -4.54747e-13, -5.68434e-14, 0, 1, 2.94416e-14, 0, -8.
shape = SubResource("SphereShape3D_eryh8")
[node name="LeftHipAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.982279, 0.127, 0.137838, 0.176971, 0.38628, 0.905245, 0.061722, 0.913597, -0.40191, 6.6331, 6.44913, -89.6507)
transform = Transform3D(-0.982279, 0.127, 0.137838, 0.176971, 0.38628, 0.905245, 0.0617221, 0.913597, -0.40191, 6.6331, 6.44913, -89.6507)
bone_name = "mixamorig_LeftUpLeg"
bone_idx = 55
@ -2935,7 +2935,7 @@ transform = Transform3D(0.997222, -0.0744854, -0.000943551, 0.0744854, 0.997222,
shape = SubResource("CapsuleShape3D_xyxrh")
[node name="LeftLegAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.982093, 0.0367378, 0.18478, 0.184413, -0.0131707, 0.982761, 0.0385382, 0.999238, 0.00616005, 11.7892, 22.1319, -52.5592)
transform = Transform3D(-0.982093, 0.0367378, 0.18478, 0.184413, -0.013171, 0.982761, 0.0385382, 0.999238, 0.00616023, 11.7892, 22.1319, -52.5592)
bone_name = "mixamorig_LeftLeg"
bone_idx = 56
@ -2950,7 +2950,7 @@ body_part = "Left Leg"
shape = SubResource("CapsuleShape3D_h5mrs")
[node name="LeftFootAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.977188, 0.206477, 0.0497126, 0.205976, 0.864368, 0.45874, 0.0517493, 0.458514, -0.887179, 13.3358, 21.5774, -10.4923)
transform = Transform3D(-0.977188, 0.206477, 0.0497126, 0.205976, 0.864368, 0.45874, 0.0517493, 0.458515, -0.887179, 13.3358, 21.5774, -10.4923)
bone_name = "mixamorig_LeftFoot"
bone_idx = 57
@ -2980,7 +2980,7 @@ body_part = "Left Arm"
shape = SubResource("CapsuleShape3D_56i6t")
[node name="LeftForearmAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(0.0873334, -0.555, -0.827253, 0.636753, 0.669735, -0.3821, 0.766106, -0.493386, 0.411888, 11.27, 33.558, -124.364)
transform = Transform3D(0.0873336, -0.555, -0.827253, 0.636753, 0.669735, -0.3821, 0.766106, -0.493386, 0.411889, 11.27, 33.558, -124.364)
bone_name = "mixamorig_LeftForeArm"
bone_idx = 9
@ -2995,7 +2995,7 @@ body_part = "Left Forearm"
shape = SubResource("CapsuleShape3D_1sjun")
[node name="LeftPalmAttachment" type="BoneAttachment3D" parent="Model/Body/Skeleton3D"]
transform = Transform3D(-0.752812, -0.657604, -0.0288319, -0.658199, 0.751583, 0.0435492, -0.00696859, 0.0517616, -0.998635, -4.05606, 52.0524, -137.988)
transform = Transform3D(-0.752812, -0.657604, -0.028832, -0.658199, 0.751584, 0.0435493, -0.00696856, 0.0517617, -0.998635, -4.05605, 52.0524, -137.988)
bone_name = "mixamorig_LeftHand"
bone_idx = 10

View File

@ -29,6 +29,7 @@ func spawn_players(spawn_location: SpawnController, id: int) -> Error:
var model: CharacterWrapper = model_scene.instantiate()
model.global_position = new_position
_get_model_root().add_child(model)
model.owner_placeholder = char
return OK
return ERR_UNAUTHORIZED

View File

@ -119,7 +119,7 @@ func _process(delta: float) -> void:
@rpc("any_peer", "call_local", "reliable")
func verify_position() -> void:
var desired_position: Vector3 = shared_node.global_position
controlled_node.send_position.rpc_id(1, desired_position.x, desired_position.y, desired_position.z)
controlled_node.send_position.rpc_id(1, desired_position)
@rpc("authority", "call_local")
func adjust_position(x: float, y: float, z: float):

View File

@ -2,13 +2,13 @@ extends Node3D
class_name ServerNode
var jumping := false
var input_direction: Vector2
var player_node: PlayerNode
# TODO: Shoould not be defined here
const DEFAULT_WEAPON := "ak"
var first_slot_weapon: WeaponController
@export var input_direction: Vector2
@export var owner_id: int = 0
@onready var camera_mount: Node3D = $SharedNode/CameraMount
@ -59,9 +59,12 @@ func _physics_process(delta: float) -> void:
shared_node.velocity.z = move_toward(shared_node.velocity.z, 0, consts.DEFAULT_CHARACTER_SPEED)
else:
print(str(name) + str(shared_node.velocity))
shared_node.move_and_slide()
if multiplayer.is_server():
shared_node.move_and_slide()
func _process(delta: float) -> void:
if not multiplayer.is_server():
shared_node.move_and_slide()
@rpc("any_peer", "call_local", "unreliable")
func jump():
jumping = true
@ -93,6 +96,10 @@ func _on_reconciliation_timer_timeout() -> void:
func _veryfy_position_and_rotation() -> void:
player_node.verify_position()
player_node.verify_rotation()
#@rpc("authority", "call_remote", "unreliable")
#func _sync_transorm():
@rpc("any_peer", "call_local", "reliable")
func _adjust_position(x: float, y: float, z: float) -> void:
@ -103,21 +110,19 @@ func _adjust_rotation(x: float, y: float, z: float) -> void:
player_node.adjust_rotation(x, y, z)
@rpc("any_peer", "call_local", "reliable")
func send_position(x: float, y: float, z: float):
func send_position(desired_position: Vector3):
if multiplayer.is_server():
var desired_position: Vector3 = Vector3(x, y, z)
if multiplayer.is_server():
var real_position: Vector3 = shared_node.global_position
var difference: Vector3 = desired_position - real_position
if is_vector_a_lower_than_b(difference, Vector3(0.2, 0.2, 0.2)):
shared_node.global_position = desired_position
elif is_vector_a_lower_than_b(difference, Vector3(0.4, 0.4, 0.4)):
var new_position: Vector3 = desired_position.lerp(real_position, 0.5)
push_warning("player position is not valid, lerping")
_adjust_position.rpc_id(owner_id, new_position.x, new_position.y, new_position.z)
else:
push_warning("player position is not valid, adjusting")
_adjust_position.rpc_id(owner_id, real_position.x, real_position.y, real_position.z)
var real_position: Vector3 = shared_node.global_position
var difference: Vector3 = desired_position - real_position
if is_vector_a_lower_than_b(difference, Vector3(0.2, 0.2, 0.2)):
shared_node.global_position = desired_position
elif is_vector_a_lower_than_b(difference, Vector3(0.4, 0.4, 0.4)):
var new_position: Vector3 = desired_position.lerp(real_position, 0.5)
push_warning("player position is not valid, lerping")
_adjust_position.rpc_id(owner_id, new_position.x, new_position.y, new_position.z)
else:
push_warning("player position is not valid, adjusting")
_adjust_position.rpc_id(owner_id, real_position.x, real_position.y, real_position.z)
@rpc("any_peer", "call_local")
func send_rotation(x: float, y: float, z: float):

View File

@ -6,7 +6,7 @@
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_2dhi2"]
properties/0/path = NodePath("SharedNode:position")
properties/0/spawn = true
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath("SharedNode:rotation")
properties/1/spawn = true
@ -14,6 +14,9 @@ properties/1/replication_mode = 1
properties/2/path = NodePath(".:owner_id")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath(".:input_direction")
properties/3/spawn = true
properties/3/replication_mode = 1
[node name="ServerNode" type="Node3D"]
script = ExtResource("1_bau14")