Godot - Get random value from array
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