21 lines
535 B
GDScript
21 lines
535 B
GDScript
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
|
|
|
|
var speed : int = 100
|
|
var direction : int = 1
|
|
|
|
signal player_slimed(body, slime)
|
|
|
|
func _process(delta: float) -> void:
|
|
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)
|