Add multiplayer damage system and ragdolls
This commit is contained in:
@ -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()
|
||||
|
@ -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
|
||||
@ -26,7 +26,15 @@ func _ready() -> void:
|
||||
$MultiplayerSpawner.spawn(char)
|
||||
players.add_child(char)
|
||||
|
||||
|
||||
var bullet_amount: int = 0
|
||||
func spawn_bullet(position):
|
||||
var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
|
||||
node.position = position.global_position
|
||||
node.transform.basis = position.global_transform.basis
|
||||
node.name = str(bullet_amount)
|
||||
bullet_amount += 1
|
||||
#$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
11
scenes/maps/hit_counter.gd
Normal file
11
scenes/maps/hit_counter.gd
Normal 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
|
17
scenes/maps/hud.gd
Normal file
17
scenes/maps/hud.gd
Normal file
@ -0,0 +1,17 @@
|
||||
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 := multiplayer.get_unique_id()
|
||||
var player_data = GameServerManager.get_player_health.rpc_id(1, id)
|
||||
health_indicator.text = str(player_data["health"])
|
||||
|
||||
pass
|
@ -13,7 +13,6 @@ func _ready() -> void:
|
||||
func _process(delta: float) -> void:
|
||||
var blue := $ChooseTeam/Blue
|
||||
var red := $ChooseTeam/Read
|
||||
if
|
||||
if raycast.is_colliding():
|
||||
var collider = raycast.get_collider()
|
||||
if collider and collider.name == target_node_name:
|
||||
|
Reference in New Issue
Block a user