Created
August 17, 2018 02:50
-
-
Save mohapsat/f6f31fa89a0184cbcd7de85bfb120379 to your computer and use it in GitHub Desktop.
[Godot 3] instance scenes from array vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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