space-invaders/scripts/enemy.gd

20 lines
460 B
GDScript3
Raw Normal View History

2026-04-22 02:17:21 +00:00
extends RigidBody2D
var direction = 1
const SPEED = 1
# signal triggerEdge(body, intentMessage)
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
var x = get_transform().get_origin().x
# not sure why rigid body doesn't see wall hardcoded walls
if x < 0 or x > 300:
# triggerEdge.emit(body, )
direction *= -1 # switch direction
move_local_x(SPEED * direction)