WIP: Spawn bullets on the server and sync them
This commit is contained in:
parent
c7c577233b
commit
9e6495ec34
@ -4,7 +4,6 @@ extends Node3D
|
||||
var owner_placeholder: CharacterBody3D = null
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print("ready")
|
||||
owner_placeholder = _get_owner()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
@ -17,6 +17,16 @@ properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:health")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 2
|
||||
properties/3/path = NodePath("FirstPersonCameraMount/HUD/HealthIndicator:text")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_toaij"]
|
||||
font_size = 70
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_1j1uq"]
|
||||
font_size = 100
|
||||
font_color = Color(0.756874, 0, 0.223924, 1)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_falg4"]
|
||||
length = 0.001
|
||||
@ -75,13 +85,6 @@ _data = {
|
||||
"shooting": SubResource("Animation_ah507")
|
||||
}
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_toaij"]
|
||||
font_size = 70
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_1j1uq"]
|
||||
font_size = 100
|
||||
font_color = Color(0.756874, 0, 0.223924, 1)
|
||||
|
||||
[node name="CharacterPlaceholder" type="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.799455, 0)
|
||||
collision_layer = 9
|
||||
@ -100,6 +103,65 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.609154, -0.209324)
|
||||
[node name="Camera" type="Camera3D" parent="FirstPersonCameraMount"]
|
||||
fov = 40.0
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="FirstPersonCameraMount/Camera"]
|
||||
visible = false
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
stretch = true
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="FirstPersonCameraMount/Camera/SubViewportContainer"]
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
size = Vector2i(1920, 1964)
|
||||
render_target_update_mode = 0
|
||||
|
||||
[node name="HUD" type="Control" parent="FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport"]
|
||||
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
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport/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("2_lsd7c")
|
||||
|
||||
[node name="HealthIndicator" type="Label" parent="FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport/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_toaij")
|
||||
|
||||
[node name="FPS" type="Label" parent="FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport/HUD" groups=["player_placeholder"]]
|
||||
layout_mode = 1
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_1j1uq")
|
||||
|
||||
[node name="BulletStartingPoint" type="Node3D" parent="FirstPersonCameraMount"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -0.42185)
|
||||
|
||||
@ -115,49 +177,5 @@ libraries = {
|
||||
"": SubResource("AnimationLibrary_u1b6p")
|
||||
}
|
||||
|
||||
[node name="HUD" type="Control" parent="FirstPersonCameraMount"]
|
||||
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
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="FirstPersonCameraMount/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("2_lsd7c")
|
||||
|
||||
[node name="HealthIndicator" type="Label" parent="FirstPersonCameraMount/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_toaij")
|
||||
|
||||
[node name="FPS" type="Label" parent="FirstPersonCameraMount/HUD" groups=["player_placeholder"]]
|
||||
layout_mode = 1
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_1j1uq")
|
||||
|
||||
[node name="ModelMount" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.790262, 0)
|
||||
|
@ -18,7 +18,7 @@ func _ready() -> void:
|
||||
char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
|
||||
char.name = "PlayerPlaceholder_" + str(GameServerManager.players[i].name)
|
||||
char.global_position = position
|
||||
var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 5.0)
|
||||
var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 20.0)
|
||||
char.global_position = position
|
||||
char.global_position.x += my_random_number
|
||||
char.global_position.y += 300 + my_random_number
|
||||
|
@ -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="Script" path="res://scenes/maps/sub_viewport_container.gd" id="8_2bwbx"]
|
||||
[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="8_h4lu1"]
|
||||
|
||||
[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_mqxor"]
|
||||
font_size = 70
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_e8hmq"]
|
||||
font_size = 100
|
||||
font_color = Color(0.756874, 0, 0.223924, 1)
|
||||
|
||||
[node name="ElTest" type="Node3D"]
|
||||
script = ExtResource("1_d5e7i")
|
||||
|
||||
@ -2569,4 +2578,64 @@ _spawnable_scenes = PackedStringArray("res://scenes/weapon/bullet.tscn")
|
||||
spawn_path = NodePath("../Bullets")
|
||||
spawn_limit = 100
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
|
||||
visible = false
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
stretch = true
|
||||
script = ExtResource("8_2bwbx")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
size = Vector2i(1920, 1964)
|
||||
render_target_update_mode = 0
|
||||
|
||||
[node name="HUD" type="Control" parent="SubViewportContainer/SubViewport"]
|
||||
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
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="SubViewportContainer/SubViewport/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="SubViewportContainer/SubViewport/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_mqxor")
|
||||
|
||||
[node name="FPS" type="Label" parent="SubViewportContainer/SubViewport/HUD" groups=["player_placeholder"]]
|
||||
layout_mode = 1
|
||||
offset_right = 40.0
|
||||
offset_bottom = 23.0
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_e8hmq")
|
||||
|
||||
[connection signal="body_part_hit" from="Dummy/Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision" to="Dummy" method="_on_head_collision_body_part_hit"]
|
||||
|
16
scenes/maps/sub_viewport_container.gd
Normal file
16
scenes/maps/sub_viewport_container.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends SubViewportContainer
|
||||
|
||||
var current_player_placeholder: Node3D = null
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#current_player_placeholder = GameServerManager.get_current_player_placeholder()
|
||||
pass # Replace with function body.
|
||||
|
||||
@onready var health_indicator: Label = $SubViewport/HUD/HealthIndicator
|
||||
@onready var fps_indicator: Label = $SubViewport/HUD/FPS
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
#if current_player_placeholder:
|
||||
#health_indicator.text = str(current_player_placeholder.health)
|
||||
#fps_indicator.text = str(Engine.get_frames_per_second())
|
||||
pass
|
@ -41,7 +41,7 @@ offset_left = 238.0
|
||||
offset_top = 151.0
|
||||
offset_right = 497.0
|
||||
offset_bottom = 220.0
|
||||
text = "192.168.0.28"
|
||||
text = "127.0.0.1"
|
||||
|
||||
[connection signal="player_connected" from="." to="." method="_on_player_connected"]
|
||||
[connection signal="player_disconnected" from="." to="." method="_on_player_disconnected"]
|
||||
|
@ -1,6 +1,16 @@
|
||||
extends Node
|
||||
|
||||
var players = {}
|
||||
|
||||
#func get_current_player_placeholder() -> Node3D:
|
||||
#var id = str(multiplayer.get_unique_id())
|
||||
#print(id)
|
||||
#var root: Window = get_tree().get_root()
|
||||
#var placeholder = root.find_child("_" + id)
|
||||
#print(placeholder)
|
||||
#return placeholder
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
@ -159,8 +159,8 @@ func _rotate_camera(sens_mod: float = 1.0) -> void:
|
||||
rotation.y -= look_dir.x * camera_sens * sens_mod
|
||||
first_view_camera_mount.rotation.x = clamp(first_view_camera_mount.rotation.x - look_dir.y * camera_sens * sens_mod, -1.5, 1.5)
|
||||
|
||||
@onready var health_indicator = $FirstPersonCameraMount/HUD/HealthIndicator
|
||||
@onready var fps_indicator = $FirstPersonCameraMount/HUD/FPS
|
||||
@onready var health_indicator = $FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport/HUD/HealthIndicator
|
||||
@onready var fps_indicator = $FirstPersonCameraMount/Camera/SubViewportContainer/SubViewport/HUD/FPS
|
||||
func _process(delta: float) -> void:
|
||||
health_indicator.text = str(health)
|
||||
fps_indicator.text = str(Engine.get_frames_per_second())
|
||||
|
Loading…
x
Reference in New Issue
Block a user