21 lines
486 B
GDScript
21 lines
486 B
GDScript
extends CSGBox3D
|
|
class_name HitDetector
|
|
|
|
var health = 5
|
|
|
|
@export var color: Color = Color(0.0, 0.0, 0.0, 0)
|
|
|
|
func hit(damage: int):
|
|
color = Color(randf(), randf(), randf(), randi())
|
|
|
|
# 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:
|
|
material.albedo_color = color
|
|
if health < 1:
|
|
queue_free()
|