20 lines
460 B
GDScript
20 lines
460 B
GDScript
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)
|