Godot Version
Question
I need multiple arrays:
bad_food is used to store elements (buttons) which are not on the scene
food is to store elements which are on the scene
extends Node2D
var bad_food = [$Button1, $Button1, $Button3]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
randomize()
var food = []
food.push_back(bad_food.pick_random())
bad_food.erase(bad_food.pick_random())
food.push_back(bad_food.pick_random())
print(food)
In the end console printing: [<Object#null>, <Object#null>] and giving an error:
E 0:00:00:0606 Button_random.gd:2 @ @implicit_new(): Node not found: “Button1” (relative to “Node2D”).