Topic was automatically imported from the old Question2Answer platform.
Asked By
Godotmus
Newbie question… I tried few ways and looks like I did not manage it to work…
Lets say I need Add my objects to an array and wan t manipulate them straight from array. (and not to fetch them temporary to Spatial variable…)
Var my_array:Spatial = # no…?
Var my_array= :Spatial # no…?
Var my_array= [:Spatial] # no…?
Var my_array= as Spatial #???..not tested…
Type hints can’t be used with arrays. The Array container in Godot is a variant container. If you have a particular need for a single-typed array, there are the Pool*Array types.
You can still add Spatial objects to your array, you just can’t specify that the array will only hold Spatials.
Pool array classes:
var my_generic_array: Array
var my_byte_array: PoolByteArray
var my_color_array: PoolColorArray
var my_int_array: PoolIntArray
var my_float_array: PoolRealArray
var my_string_array: PoolStringArray
var my_vector2_array: PoolVector2Array
var my_vector3_array: PoolVector3Array