WIP: Spawn bullets on the server and sync them

This commit is contained in:
Nikolai Rodionov 2025-01-26 21:57:09 +01:00
parent 5678ddb4c1
commit c7c577233b
Signed by: allanger
GPG Key ID: 09F8B434D0FDD99B
5 changed files with 9 additions and 8 deletions

View File

@ -15,10 +15,10 @@ func _process(delta: float) -> void:
func _on_head_collision_body_part_hit(dam: Variant) -> void: func _on_head_collision_body_part_hit(dam: Variant) -> void:
print("head is hit" + str(dam)) #print("head is hit" + str(dam))
print(owner_placeholder) #print(owner_placeholder)
if owner_placeholder.has_method("take_damage"): #if owner_placeholder.has_method("take_damage"):
owner_placeholder.take_damage(dam) owner_placeholder.take_damage(dam)
pass # Replace with function body. pass # Replace with function body.
func _get_owner() -> CharacterBody3D: func _get_owner() -> CharacterBody3D:

View File

@ -16,7 +16,7 @@ properties/1/spawn = true
properties/1/replication_mode = 1 properties/1/replication_mode = 1
properties/2/path = NodePath(".:health") properties/2/path = NodePath(".:health")
properties/2/spawn = true properties/2/spawn = true
properties/2/replication_mode = 1 properties/2/replication_mode = 2
[sub_resource type="Animation" id="Animation_falg4"] [sub_resource type="Animation" id="Animation_falg4"]
length = 0.001 length = 0.001

View File

@ -16,7 +16,7 @@ func _ready() -> void:
if multiplayer.is_server(): if multiplayer.is_server():
for i in GameServerManager.players: for i in GameServerManager.players:
char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate() char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
char.name = "PlayerPlaceholder" + str(GameServerManager.players[i].name) char.name = "PlayerPlaceholder_" + str(GameServerManager.players[i].name)
char.global_position = position 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, 5.0)
char.global_position = position char.global_position = position

View File

@ -26,8 +26,8 @@ func _process(delta):
if collider != null and collider.is_in_group("target"): if collider != null and collider.is_in_group("target"):
ray.get_collider().take_damage() ray.get_collider().take_damage()
if collider != null and collider.is_in_group("body"): if collider != null and collider.is_in_group("body"):
print(collider)
ray.get_collider().hit() ray.get_collider().hit()
print("I got hit")
rigid_body_3d.visible = false rigid_body_3d.visible = false
particles.emitting = true particles.emitting = true
#if ray.get_collider().is_in_group("body"): #if ray.get_collider().is_in_group("body"):

View File

@ -256,4 +256,5 @@ func _hit_scan_damage(Collider):
func take_damage(dam: int): func take_damage(dam: int):
print("damage") print("damage")
health =- dam health -= dam
print(health)