15 lines
319 B
GDScript
15 lines
319 B
GDScript
extends CharacterBody2D
|
|
|
|
var health = 5
|
|
@onready var player = get_node("/root/Game/player")
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
var direction = global_position.direction_to(player.global_position)
|
|
velocity = direction * 50
|
|
move_and_slide()
|
|
|
|
func take_damage():
|
|
health -= 1
|
|
if health == 0:
|
|
queue_free()
|