Hello, I'm new to godot and programming. Problem is, I can not get my ship to fire. I have created a sprite-type node named "sprnaveshoots" that initialized in graph 2d with the parameter "visible" disabled. Then, in the parent script, create an empty array. When left-clicking the mouse, I have told godot that, this value is equal to the sprite "sprnaveshoots" with the difference that it will have the "visible" property activated. Once the sprite is stored inside the array, it will proceed to move the sprite, but when I try to get the position of the sprite and modify it, godot retorn me following error message: "Invalid get index '[Sprite: 563]' (Based on 'Array'). ".
These is my code:
extends Node2D
onready var nave = get_node("spr_nave")
onready var nave_prt = get_node("prt_nave")
onready var nave_shoot = get_node("spr_nave_shoot")
onready var nave_shoots = []
func _ready():
set_process(true)
func _process(delta):
action_nave(delta)
mover_disparos_nave(delta)
func move_shoot(shoot,delta):
var sh = shoot
var sh_p = shoot.get_pos()
func mover_disparos_nave(delta):
for i in nave_shoots:
move_shoot(nave_shoots[i],delta)
func disparar(delta):
#var pos = nave_shoot.get_pos()
#pos.y -=200*delta
#nave_shoot.set_pos(pos)
var disparo = nave_shoot
var dis_pos = disparo.get_pos()
dis_pos = nave.get_pos()
disparo.show()
disparo.set_pos(dis_pos)
nave_shoots.push_back(disparo)
func action_nave(delta):
if(Input.is_action_pressed("spr_nave_shoot")):
disparar(delta)
Thanks!