Added enemy collision

This commit is contained in:
2024-02-13 10:38:26 +01:00
parent 6727be5cd0
commit a510a5bb7b
4 changed files with 33 additions and 4 deletions

View File

@ -0,0 +1,7 @@
extends Area3D
func on_body_entered(body: Node3D):
var health := body.get_node_or_null("Health") as HealthComponent
if health:
health.take_damage(DamageInstance.new(10))

View File

@ -8,4 +8,8 @@ func _ready():
player.attacked.connect(attack)
func attack():
%Health.take_damage(DamageInstance.new(10))
var area := %MeleeArea as Area3D
await get_tree().create_timer(0.5).timeout
area.monitoring = true
await get_tree().create_timer(0.1).timeout
area.monitoring = false