Hi again. As I said earlier, I'm making mi first game, a Space Invaders clone. I made some design mistakes but I'm on the good way. For now, I made a Node2D to do the tasks of creating formations and move they. I wanted the formation drop 16 píxels every time a invader touchs the limit I want. I though that a Tween node will do the work well but every time I try to run the scene with the Tween node attached as child of the Node2D (the way I think has to be) I obtained an error "Invalid get Index 'x' (on base: 'Nil') at line 31. It's strange because before adding the tween node, or even if I delete it, the scene works well. ¿Any idea? I can't understand the interrelation between the Tween and the error message.

extends Node2D
export (PackedScene) var Baboso_Basic
onready var tween = get_node("Tween")
const formation = Vector2 (6, 3)
var velocity = Vector2(1, 0)
var speed = 25
func _ready():
position = Vector2(24, 24)
for y in range (formation.y):
var babosoPos = Vector2(0, (y * 20))
for x in range (formation.x):
babosoPos.x = (x * 24)
var baboso = Baboso_Basic.instance()
baboso.position = babosoPos
add_child(baboso)
func move_formation(delta):
position += (velocity * speed) * delta
func if_border_reached():
for baboso in get_children():
if left_border_reached(baboso) or right_border_reached(baboso):
get_down()
velocity = -velocity
break
func left_border_reached(baboso):
if velocity.x < 0.0:
if baboso.global_position.x < 20:
return true
return false
func right_border_reached(baboso):
if velocity.x > 0.0:
if baboso.global_position.x > 300:
return true
return false
func get_down():
tween.interpolate_property(self, "position",
position, position + Vector2(0, 16), 2,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
func _process(delta):
move_formation(delta)
if_border_reached()