Flopsy/objects/characters/monsters/01/monster_01.gd
2022-07-17 14:24:15 +02:00

20 lines
641 B
GDScript

extends "res://objects/characters/monsters/monster.gd"
func _process(delta):
if motion != null:
if not $RayBottomLeft.is_colliding():
motion.x = speed
if not $RayBottomRight.is_colliding():
motion.x = -speed
if $RayPlayerLeft.is_colliding():
var collider = $RayPlayerLeft.get_collider()
collider.monster_hit(-speed, DAMAGE)
if $RayPlayerRight.is_colliding():
var collider = $RayPlayerRight.get_collider()
collider.monster_hit(speed, DAMAGE)
func stomped_on_head():
if not $RayPlayerLeft.is_colliding() and not $RayPlayerRight.is_colliding():
health = 0
$Sprite.animation = "stomped"
$StampedSound.play()