WIP: Start working on the frag/damage system
This commit is contained in:
24
scenes/maps/tools/hit_detector.gd
Normal file
24
scenes/maps/tools/hit_detector.gd
Normal file
@ -0,0 +1,24 @@
|
||||
extends CSGBox3D
|
||||
class_name HitDetector
|
||||
|
||||
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 hit(damage: int):
|
||||
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.
|
||||
|
||||
|
||||
# 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()
|
24
scenes/maps/tools/hit_detector.tscn
Normal file
24
scenes/maps/tools/hit_detector.tscn
Normal file
@ -0,0 +1,24 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cdcbn8mglqlyh"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/maps/tools/hit_detector.gd" id="1_4w4v8"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_8tws6"]
|
||||
properties/0/path = NodePath("Box:color")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_petk4"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5m44n"]
|
||||
|
||||
[node name="HitDetector" type="Node3D"]
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="." groups=["target"]]
|
||||
replication_config = SubResource("SceneReplicationConfig_8tws6")
|
||||
|
||||
[node name="Box" type="CSGBox3D" parent="." groups=["target"]]
|
||||
material_override = SubResource("StandardMaterial3D_petk4")
|
||||
use_collision = true
|
||||
collision_layer = 9
|
||||
material = SubResource("StandardMaterial3D_5m44n")
|
||||
script = ExtResource("1_4w4v8")
|
Reference in New Issue
Block a user