0 votes

hi i have a question, i am new to godot and i have 4 tscn files and when i press key i want it to randomly select one of these scenes how can i do that exactly?

Godot version Godot v 3.5
related to an answer for: Load Random Scenes
in Engine by (12 points)

1 Answer

0 votes

var newsceneclass
var idx = RandomNumberGenerator.new().randirange(1, 4)
if idx == 1:
new
scene_class = preload("myscene1.tscn")
etc....

var newscene = newscene_class.instance()

by (1,053 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.