WIP: Spawn bullets on the server and sync them

This commit is contained in:
Nikolai Rodionov 2025-01-26 20:20:15 +01:00
parent c2a5f9cf1c
commit 24914cb6fa
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
8 changed files with 17 additions and 7 deletions

View File

@ -36,6 +36,7 @@ import/blender/enabled=false
body=""
target=""
player_placeholder=""
[input]

View File

@ -16,10 +16,11 @@ func _process(delta: float) -> void:
func _on_head_collision_body_part_hit(dam: Variant) -> void:
print("head is hit" + str(dam))
#owner_placeholder.take_damage(dam)
print(owner_placeholder)
owner_placeholder.take_damage(dam)
pass # Replace with function body.
func _get_owner() -> CharacterBody3D:
var owner_placeholder := find_parent("CharacterPlaceholder")
var owner_placeholder := find_parent("PlayerPlaceholder*")
return owner_placeholder

View File

@ -1344,7 +1344,7 @@ surface_material_override/0 = SubResource("StandardMaterial3D_j3emx")
[node name="HitCollisions" type="Node3D" parent="Body/Armature/Skeleton3D"]
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="Body/Armature/Skeleton3D"]
transform = Transform3D(0.978017, -0.176546, -0.110973, 0.15839, 0.282801, 0.946011, -0.135631, -0.942791, 0.304547, -11.8203, 17.7472, -135.936)
transform = Transform3D(0.978017, -0.176546, -0.110972, 0.15839, 0.282801, 0.94601, -0.135631, -0.942791, 0.304547, -11.8203, 17.7472, -135.936)
bone_name = "mixamorig_Head"
bone_idx = 5

View File

@ -1,6 +1,6 @@
extends Area3D
@export var damage: int = 100
@export var damage: int = 20
signal body_part_hit(dam)
# Called when the node enters the scene tree for the first time.

View File

@ -14,6 +14,9 @@ properties/0/replication_mode = 1
properties/1/path = NodePath(".:rotation")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath(".:health")
properties/2/spawn = true
properties/2/replication_mode = 1
[sub_resource type="Animation" id="Animation_falg4"]
length = 0.001
@ -149,7 +152,7 @@ grow_vertical = 0
text = "100"
label_settings = SubResource("LabelSettings_toaij")
[node name="FPS" type="Label" parent="FirstPersonCameraMount/HUD"]
[node name="FPS" type="Label" parent="FirstPersonCameraMount/HUD" groups=["player_placeholder"]]
layout_mode = 1
offset_right = 40.0
offset_bottom = 23.0

View File

@ -16,7 +16,7 @@ func _ready() -> void:
if multiplayer.is_server():
for i in GameServerManager.players:
char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
char.name = str(GameServerManager.players[i].name)
char.name = "PlayerPlaceholder" + str(GameServerManager.players[i].name)
char.global_position = position
var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 5.0)
char.global_position = position

View File

@ -22,6 +22,11 @@ func _process(delta):
#ray.collision_mask = 1
#ray.enabled = 1
if ray.is_colliding():
var collider = ray.get_collider()
if collider != null and collider.is_in_group("target"):
ray.get_collider().take_damage()
if collider != null and collider.is_in_group("body"):
ray.get_collider().hit()
print("I got hit")
rigid_body_3d.visible = false
particles.emitting = true

View File

@ -3,7 +3,7 @@
# ---------------------------------------------------------------------
class_name PlayerInput extends CharacterBody3D
var health: int = 100
@export var health: int = 100
@export_category("PlayerInput")