Export array in a inherited scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lsgrandchamp

I have a “parent” scene called “Enemy” that exports an empty array of strings:

export(Array, String) var idles = []

Then I inherit this scene in some children, such as “EnemyRanged” and “EnemyMelee”. When creating my levels, I put some of these two on my map, setting the array elements in the inspector in each of them.

The problem is: The array is always empty, despite adding elements using the inspector.

I’ve read that in previous versions, the array data was shared between all instances. Is that still a thing on 3.2?


:bust_in_silhouette: Reply From: vulpido

try exporting a PoolStringArray instead

:bust_in_silhouette: Reply From: tuon

Yes, it’s still an issue in Godot 3.2.2. However, if you remove “= ” in the declaration it seems to clear it up.

Please see this youtube video where Gonkee describes the same issue. However, several comments say removing “= ” fixes it. I have not tried this myself. Hope it works out!

Gonkee’s Export Array Bug in Godot Youtube Video

I can confirm that removing “=” fixes the issue.

lsgrandchamp | 2020-08-13 01:46

I’m having this issue with Godot 3.5.1 exporting an array from a class and when i use the inspector to populate that array in a sub-class, it’s always empty. Even after removing the from the declaration.

I had to do the following for it to work:

class_name A extends Node2D

export(Array) var SomeArray : Array

var some_array

func _ready():
   some_array = SomeArray

Then I can populate the array via inspector in the sub-class. Otherwise, always comes empty.

Pdcl | 2022-11-02 00:59