Tutorial 17 Enemy AI and Stats

This commit is contained in:
Alan Youngblood
2024-11-20 17:22:31 -05:00
parent 23a693d4a9
commit 24bc047855
14 changed files with 88 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ extends KinematicBody2D
var velocity = Vector2.ZERO
var input_vector = Vector2.ZERO
var roll_vector = Vector2.DOWN
var stats = PlayerStats
const ACCELERATION = 500
const MAX_SPEED = 80
@@ -21,8 +22,10 @@ onready var animationPlayer = $AnimationPlayer
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
onready var swordHitbox = $HitboxPivot/SwordHitbox
onready var hurtBox = $Hurtbox
func _ready():
stats.connect("no_health", self, "queue_free")
animationTree.active = true
swordHitbox.knockback_vector = roll_vector
@@ -90,3 +93,9 @@ func attack_aninimation_finished():
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Hurtbox_area_entered(area):
stats.health -= 1
hurtBox.start_invincibility(0.5)
hurtBox.create_hit_effect()