Material Box

Material Box

WEB Design & Material Images

Godot - Get random value from array

Godot

GDScript code example to get a random value from an array.


In GDScript, pick_random() can be used to get a random value from an array.
If the specified array is empty, it returns "null".

var array = ["apple", "lemon", "banana", "apple"]
var random = array.pick_random()

print(random)
# banana

Godot

TitleGodot - Get random value from array

CategoryGodot

Created

Update

AuthorYousuke.U