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()
