You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
449 B
GDScript

extends Position3D
var maxX = 20
var minX = -20
var SPEED = 10
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