WIP: Spawn bullets on the server and sync them

This commit is contained in:
2025-01-26 18:18:35 +01:00
parent adce112be9
commit e28845b688
11 changed files with 1467 additions and 18 deletions

View File

@ -2,8 +2,15 @@ extends CSGBox3D
var health = 5
@export var color: Color = Color(0, 0, 0)
var colors = [Color(1.0, 0.0, 0.0, 1.0),
Color(0.0, 1.0, 0.0, 1.0),
Color(0.0, 0.0, 1.0, 0.0)]
func take_damage():
health -= 1
color = Color(randf(), randf(), randf())
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
@ -11,5 +18,6 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
material_override.albedo_color = color
if health < 1:
queue_free()

View File

@ -26,7 +26,13 @@ func _ready() -> void:
$MultiplayerSpawner.spawn(char)
players.add_child(char)
func spawn_bullet(position):
print("spawning a bullet")
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
node.position = position.global_position
node.transform.basis = position.global_transform.basis
$BulletSpawner.spawn(node)
$Bullets.add_child(node)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
extends CSGBox3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass