class_name Slime extends Area2D signal playerDamagSignal @onready var right_cast: RayCast2D = $rightCast @onready var left_cast: RayCast2D = $leftCast @onready var right_cast_floor: RayCast2D = $rightCastFloor @onready var left_cast_floor: RayCast2D = $leftCastFloor var speed = 100 var direction = 1 func _process(delta: float) -> void: if not right_cast_floor.is_colliding(): direction = -1 if not left_cast_floor.is_colliding(): direction = 1 if right_cast.is_colliding(): var body = right_cast.get_collider() if not body is Player: direction = -1 if left_cast.is_colliding(): var body = left_cast.get_collider() if not body is Player: direction = 1 position.x += direction*speed*delta func _on_body_entered(body: Node2D) -> void: playerDamagSignal.emit(body, self) print("bad guy yum yum")