25 lines
		
	
	
		
			646 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			646 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
class_name Slime extends Area2D
 | 
						|
@onready var right_cast = $RightCast
 | 
						|
@onready var left_cast = $LeftCast
 | 
						|
@onready var right_down_cast = $RightDownCast
 | 
						|
@onready var left_down_cast = $LeftDownCast
 | 
						|
 | 
						|
var speed:int = 100
 | 
						|
var direction = 1
 | 
						|
 | 
						|
signal slimeDamageSignal(body, slime)
 | 
						|
# Called when the node enters the scene tree for the first time.
 | 
						|
func _ready():
 | 
						|
	pass # Replace with function body.
 | 
						|
 | 
						|
 | 
						|
# Called every frame. 'delta' is the elapsed time since the previous frame.
 | 
						|
func _process(delta):
 | 
						|
	position.x += direction * speed * delta
 | 
						|
 | 
						|
 | 
						|
func _on_body_entered(body):
 | 
						|
	print("slime detects body")
 | 
						|
	if body is Player:
 | 
						|
		slimeDamageSignal.emit(body, self)
 |