In my script I have an array (plan) that is initialized as an empty array. Then, in my "_process" function, I make a call to plan.size() that's required for later code. The problem is, when I play the project I get an error "Invalid call. Nonexistent function 'size' in base 'Nil'."
I can "trick" it into compiling properly if I initialize the array inside the _process function, but I don't want the array to be re-set to empty every time it updates.
Here is the code I'm using:
extends Node2D
var state = "idle"
var plan = [] #this is the array
func _ready():
set_process(true)
func _process(delta):
#if I initialize the array here it will compile
if (state == "idle"):
if (plan.size() > 0): #this is the line that causes the error
etc...
Is there a way to fix this? Thanks.