+1 vote

Hello all again, I want to check if a certain scene exist. How can I do that?

in Engine by (171 points)

2 Answers

0 votes

You can check if a file exists using:
https://docs.godotengine.org/en/latest/classes/class_file.html#class-file-method-file-exists

You can also see examples of how to use the File object farther up that page.

by (20,381 points)
0 votes

For example:

export(String, FILE, "*.tscn") var path_to_scene

func change_scene():
    if ResourceLoader.exists(path_to_scene):
        var _error = get_tree().change_scene(path_to_scene)
by (211 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 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 webmaster@godotengine.org with your username.