class_name purpleslime extends Area2D @onready var sprite: AnimatedSprite2D = $AnimatedSprite2D @onready var rightray: RayCast2D = $rightray @onready var leftray: RayCast2D = $leftray @onready var rightfloorray: RayCast2D = $rightfloorray @onready var leftfloorray: RayCast2D = $leftfloorray const speed = 60 var direction = 1 #signals signal playerDamage func _process(delta: float) -> void: if not rightfloorray.is_colliding(): direction = -1 sprite.flip_h = true #about to fall on the right if not leftfloorray.is_colliding(): direction = 1 sprite.flip_h = false #about to fall on the right position.x += direction * speed * delta func _on_body_entered(body: Node2D) -> void: if body.is_in_group("player"): print("bad guy collected") playerDamage.emit() if body.is_in_group("destructable"): print("box hit")