Flopsy/objects/characters/monsters/02/monster_02.gd

21 lines
581 B
GDScript3
Raw Normal View History

2022-07-19 18:11:23 +02:00
extends "res://objects/characters/monsters/static_monster.gd"
export var sleep_down : float = 5.0
export var sleep_up : float = 2.0
func _ready():
$Animation.play("move")
func _on_Animation_finished(anim_name):
if anim_name == "move" and health > 0:
if $Sprite.position.y >= 0:
yield(get_tree().create_timer(sleep_down), "timeout")
$Animation.play("move")
else:
yield(get_tree().create_timer(sleep_up), "timeout")
$Animation.play_backwards("move")
func _on_PlayerCollision(body):
if $Sprite.position.y <= 0:
body.monster_hit(-body.velocity.x / 10, damage)