class_name Slimer extends Area2D @onready var right_cast: RayCast2D = $RightCast @onready var left_cast: RayCast2D = $LeftCast @onready var right_down_cast: RayCast2D = $RightDownCast @onready var left_down_cast: RayCast2D = $LeftDownCast @onready var slime_sprite: AnimatedSprite2D = $SlimeSprite var speed : int = 25 var direction : int = 1 signal player_slimed(body, slime) func _process(delta: float) -> void: if not right_down_cast.is_colliding(): direction = -1 slime_sprite.flip_h = true #if not left_down_cast.is_colliding(): #direction = 1 #slime_sprite.flip_h = false #if not right_cast.is_colliding(): #direction = -1 #slime_sprite.flip_h = true #if not left_cast.is_colliding(): #direction = 1 #slime_sprite.flip_h = false position.x += direction * speed * delta func _on_body_entered(body: Node2D) -> void: if body is Player: print_debug("Player hit Slimer") player_slimed.emit(body, self)