WIP: Spawn bullets on the server and sync them

This commit is contained in:
Nikolai Rodionov 2025-01-26 23:05:21 +01:00
parent c7c577233b
commit 5c360932fd
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
3 changed files with 74 additions and 1 deletions

View File

@ -116,6 +116,7 @@ libraries = {
}
[node name="HUD" type="Control" parent="FirstPersonCameraMount"]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=93 format=4 uid="uid://c1v6kb00y77ij"]
[gd_scene load_steps=97 format=4 uid="uid://c1v6kb00y77ij"]
[ext_resource type="Script" path="res://scenes/maps/el_test.gd" id="1_d5e7i"]
[ext_resource type="Texture2D" uid="uid://60qg81svnxfd" path="res://assets/models/maps/el_test_Image_0.png" id="2_o6seo"]
@ -7,6 +7,8 @@
[ext_resource type="Script" path="res://scenes/maps/csg_box_3d.gd" id="5_3oqpw"]
[ext_resource type="Script" path="res://scenes/characters/blue/dummy.gd" id="6_m5xfd"]
[ext_resource type="Script" path="res://scenes/characters/blue/head_collision.gd" id="7_yqr12"]
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="8_h4lu1"]
[ext_resource type="Script" path="res://scenes/maps/hud.gd" id="8_h81ia"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1on1b"]
resource_name = "Orange_Playground_Base_Color"
@ -1709,6 +1711,13 @@ _data = {
"Run Forward": SubResource("Animation_6g1lc")
}
[sub_resource type="LabelSettings" id="LabelSettings_ue1xd"]
font_size = 70
[sub_resource type="LabelSettings" id="LabelSettings_ht855"]
font_size = 100
font_color = Color(0.756874, 0, 0.223924, 1)
[node name="ElTest" type="Node3D"]
script = ExtResource("1_d5e7i")
@ -2569,4 +2578,49 @@ _spawnable_scenes = PackedStringArray("res://scenes/weapon/bullet.tscn")
spawn_path = NodePath("../Bullets")
spawn_limit = 100
[node name="HUD" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 8.0
offset_right = 8.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("8_h81ia")
[node name="TextureRect" type="TextureRect" parent="HUD"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -36.0
offset_top = -36.0
offset_right = 36.0
offset_bottom = 36.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("8_h4lu1")
[node name="HealthIndicator" type="Label" parent="HUD"]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -23.0
offset_right = 40.0
grow_vertical = 0
text = "100"
label_settings = SubResource("LabelSettings_ue1xd")
[node name="FPS" type="Label" parent="HUD" groups=["player_placeholder"]]
layout_mode = 1
offset_right = 40.0
offset_bottom = 23.0
text = "0"
label_settings = SubResource("LabelSettings_ht855")
[connection signal="body_part_hit" from="Dummy/Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision" to="Dummy" method="_on_head_collision_body_part_hit"]

18
scenes/maps/hud.gd Normal file
View File

@ -0,0 +1,18 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
@onready var health_indicator: Label = $HealthIndicator
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var root := get_tree().get_root()
var id := str(multiplayer.get_unique_id())
var placeholder: Node3D = root.find_child("*_" + id)
if placeholder:
health_indicator.text = placeholder.health
pass