SeptemberGame/scripts/slime.gd

27 lines
731 B
GDScript3
Raw Normal View History

class_name Slime 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 = 1
signal slimeDamageSignal(body, slime)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
position.x += direction * speed * delta
func _on_body_entered(body: Node2D) -> void:
print("slime detects body")
if body is Player:
slimeDamageSignal.emit(body, self)