feat: integrated some assets and made a hitbox and damage reaction system
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var time_to_finish_hit: Timer = $TimeToFinishHit
|
||||
@onready var hitbox: Area2D = $Hitbox
|
||||
|
||||
func _ready() -> void:
|
||||
hitbox.monitoring = false
|
||||
|
||||
func play_anim_run():
|
||||
animated_sprite.play("run")
|
||||
@ -10,3 +15,13 @@ func play_anim_idle():
|
||||
|
||||
func hit():
|
||||
animated_sprite.play("hit")
|
||||
time_to_finish_hit.start()
|
||||
hitbox.monitoring = true
|
||||
|
||||
func _on_trigger_hit_body_entered(body: Node2D) -> void:
|
||||
if body.name == "Player":
|
||||
hit()
|
||||
|
||||
func _on_time_to_finish_hit_timeout() -> void:
|
||||
play_anim_idle()
|
||||
hitbox.monitoring = false
|
||||
|
Reference in New Issue
Block a user