WIP: Some updates

This commit is contained in:
2025-02-09 20:14:24 +01:00
parent 275d697f60
commit ccc43e9c4b
9 changed files with 93 additions and 66 deletions

View File

@ -39,9 +39,9 @@ func _ready() -> void:
hud_camera = hud.camera
gun_mount = hud.gun_mount
_load_weapon()
for child in controlled_node.find_child("Model").find_children("*"):
if child is MeshInstance3D:
child.set_layer_mask_value(1, false)
#for child in controlled_node.find_child("Model").find_children("*"):
#if child is MeshInstance3D:
#child.set_layer_mask_value(1, false)
# Load the default weapon and set the current attack properties
func _load_weapon() -> void:
@ -64,19 +64,17 @@ func initial_position_sync():
func _input(event):
if multiplayer.get_unique_id() == get_multiplayer_authority():
if Input.is_action_just_pressed("jump"): jump()
if Input.is_action_just_released("shoot"): shooting = false
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
look_dir = event.relative * 1
shared_node.rotation.y -= look_dir.x * camera_sens * 1.0
camera_mount.rotation.x = clamp(camera_mount.rotation.x - look_dir.y * camera_sens * 1.0, -1.5, 1.5)
controlled_node.set_rotation_x.rpc_id(1, camera_mount.rotation.x)
controlled_node.set_rotation_y.rpc_id(1, shared_node.rotation.y)
if Input.is_action_pressed("move_left") or Input.is_action_pressed("move_right") or Input.is_action_pressed("move_forward") or Input.is_action_pressed("move_backward"):
moving = true
else:
moving = false
input_direction = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
controlled_node.set_input_direction.rpc_id(1, input_direction)
if Input.is_action_just_pressed("shoot"): shooting = true
if Input.is_action_just_released("shoot"): shooting = false

View File

@ -23,12 +23,7 @@ func _ready() -> void:
shared_node.set_collision_mask_value(3, true)
map_controller = find_parent("Map")
_load_weapon()
var model_scene: PackedScene = ResourceLoader.load("res://scenes/characters/y-bot/character.tscn")
var model: CharacterWrapper = model_scene.instantiate()
model.global_position = shared_node.global_position
model.set_owner_placeholder(shared_node)
shared_node.add_child(model)
map_controller.spawn_player_model(shared_node)
# Load the default weapon and set the current attack properties
func _load_weapon() -> void:
@ -55,12 +50,10 @@ func _physics_process(delta: float) -> void:
var direction := (shared_node.transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized()
if shared_node.is_on_floor():
if direction:
$SharedNode/Character/Model/AnimationPlayer.play("riffle_run")
#first_view_legs_anim.play("Run Forward")
shared_node.velocity.x = direction.x * consts.DEFAULT_CHARACTER_SPEED
shared_node.velocity.z = direction.z * consts.DEFAULT_CHARACTER_SPEED
else:
$SharedNode/Character/Model/AnimationPlayer.play("riffle_idle")
shared_node.velocity.x = move_toward(shared_node.velocity.x, 0, consts.DEFAULT_CHARACTER_SPEED)
shared_node.velocity.z = move_toward(shared_node.velocity.z, 0, consts.DEFAULT_CHARACTER_SPEED)
shared_node.move_and_slide()

View File

@ -1,39 +1,29 @@
[gd_scene load_steps=6 format=3 uid="uid://clq0b7tbincut"]
[gd_scene load_steps=4 format=3 uid="uid://clq0b7tbincut"]
[ext_resource type="Script" path="res://scenes/player/server_node.gd" id="1_bau14"]
[ext_resource type="PackedScene" uid="uid://cirun2v34nfpg" path="res://scenes/player/shared_node.tscn" id="1_ybp5y"]
[ext_resource type="PackedScene" uid="uid://ddwrs0so7swxn" path="res://scenes/characters/y-bot/character.tscn" id="3_eykxo"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_2dhi2"]
properties/0/path = NodePath("SharedNode:position")
properties/0/path = NodePath("SharedNode:rotation")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath("SharedNode:rotation")
properties/1/path = NodePath(".:owner_id")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath(".:owner_id")
properties/1/replication_mode = 2
properties/2/path = NodePath(".:input_direction")
properties/2/spawn = true
properties/2/replication_mode = 2
properties/3/path = NodePath(".:input_direction")
properties/2/replication_mode = 1
properties/3/path = NodePath(".:jumping")
properties/3/spawn = true
properties/3/replication_mode = 0
properties/4/path = NodePath(".:jumping")
properties/4/spawn = true
properties/4/replication_mode = 0
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_8la7e"]
properties/0/path = NodePath("SharedNode:position")
properties/0/spawn = false
properties/0/replication_mode = 0
properties/3/replication_mode = 1
[node name="ServerNode" type="Node3D"]
script = ExtResource("1_bau14")
[node name="SharedNode" parent="." instance=ExtResource("1_ybp5y")]
[node name="Character" parent="SharedNode" instance=ExtResource("3_eykxo")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
visible = false
[node name="CSGBox3D" type="CSGBox3D" parent="SharedNode"]
transform = Transform3D(0.190118, 0, 0, 0, 0.190118, 0, 0, 0, 0.190118, 0, 1.62415, -2.41805)
[node name="MainSynchronizer" type="MultiplayerSynchronizer" parent="."]
replication_config = SubResource("SceneReplicationConfig_2dhi2")
@ -43,10 +33,4 @@ visibility_update_mode = 1
wait_time = 0.1
autostart = true
[node name="PositionSync" type="MultiplayerSynchronizer" parent="."]
replication_interval = 0.05
delta_interval = 0.05
replication_config = SubResource("SceneReplicationConfig_8la7e")
visibility_update_mode = 1
[connection signal="timeout" from="ReconciliationTimer" to="." method="_on_reconciliation_timer_timeout"]