Material Box

Material Box

WEB Design & Material Images

Godot - Duplicate an Array

Godot

GDScript code example to duplicate an array.


In GDScript, you can use duplicate() to create a duplicate of an array.
The duplicated array created with duplicate() is independent and does not share its content with the original array.
You can set the argument to create a deep copy to "true" or "false (default)".

var array = ["apple", "lemon", "banana"]
var array1 = array
var array2 = array.duplicate()

array[0] = "pineapple"

print(array1)
# ["pineapple", "lemon", "banana"]

print(array2)
# ["apple", "lemon", "banana"]

Godot

TitleGodot - Duplicate an Array

CategoryGodot

Created

Update

AuthorYousuke.U