![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Tiago Fernandes |
I made a script to move out of point A and go to point B and then back to point A and do so forever.
But it only makes the first block of the script and stops.
extends Node2D
var speed = 200
var pos_inicial
var pos_final
func _ready():
set_process(true)
pos_inicial = true
pos_final = false
func _process(delta):
var move = Vector2()
if $".".position.x <= 700 && pos_inicial == true:
move.x = speed
if $".".position.x >= 700:
pos_inicial = false
pos_final = true
if $".".position.x >= 10 && pos_final == true:
move.x = -speed
if $".".position.x <= 10:
pos_inicial = true
pos_final = false
position += move * delta