These days we've implemented differents kinds of meteors in our game
For this, we've created the following code :
var meteors = [
preload("res://meteors/meteor1.tscn"),
preload("res://meteors/meteor2.tscn"),
preload("res://meteors/meteor3.tscn"),
preload("res://meteors/meteor4.tscn"),
preload("res://scenes/meteor.tscn")
]
Here we create an array where we load all the different instances of the meteors.
Then when we need to create a new one in the game, we randomly choose one from the array, and set the position also randomly.
func create_meteor():
var meteor_n = meteors[randi_range(0, meteors.size()-1)].instantiate()
meteor_n.position.y = -25
meteor_n.position.x = randi() % 440 + 20
# Spawn the mob by adding it to the Main scene.
add_child(meteor_n)