extends Position3D var maxX = 10 var minX = -10 var SPEED = 1 var state = -1 # Called when the node enters the scene tree for the first time. func _ready(): pass func _process(delta): if self.translation.x < minX or self.translation.x > maxX: self.state *= -1 if state == -1: # moving negative self.transform.origin += Vector3(1, 0, 0) * SPEED * delta elif state == 1: self.transform.origin += Vector3(-1, 0, 0) * SPEED * delta