Added a loot component
This commit is contained in:
15
client/enemy/loot/LootComponent.gd
Normal file
15
client/enemy/loot/LootComponent.gd
Normal file
@ -0,0 +1,15 @@
|
||||
class_name LootComponent
|
||||
extends Node
|
||||
|
||||
@export var health: HealthComponent
|
||||
@export var drop: PackedScene
|
||||
|
||||
func _ready():
|
||||
health.death.connect(on_death)
|
||||
|
||||
func on_death():
|
||||
prints(owner.name, "death")
|
||||
var loot := drop.instantiate() as Node3D
|
||||
owner.get_parent().add_child(loot)
|
||||
loot.global_position = owner.global_position + loot.position
|
||||
owner.queue_free()
|
6
client/enemy/loot/LootComponent.tscn
Normal file
6
client/enemy/loot/LootComponent.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bfvudkup0xsq4"]
|
||||
|
||||
[ext_resource type="Script" path="res://enemy/loot/LootComponent.gd" id="1_5qhry"]
|
||||
|
||||
[node name="Loot" type="Node"]
|
||||
script = ExtResource("1_5qhry")
|
Reference in New Issue
Block a user