Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bitmammoth/7c563ce752276d816e96d1954ca34482 to your computer and use it in GitHub Desktop.
Save bitmammoth/7c563ce752276d816e96d1954ca34482 to your computer and use it in GitHub Desktop.
[Godot 3] instance scenes from array vars
# Create 2 scenes 0.tscn and 1.tscn
# Add a Node and call it main
# Add script as below to main
extends Node
var scenes = [0,1]
func _ready():
# randomize()
for id in scenes:
var scene_path = "res://"+str(scenes[id])+".tscn"
# print("scene path = " + str(scene_path))
var scene_pre = load(str(scene_path)) # use load instead of preload
var scene = scene_pre.instance()
add_child(scene)
func _process(delta):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment