|Attention||Topic was automatically imported from the old Question2Answer platform.|
Hello, I am trying to make a scene where, when the enemy “catches” the player, they go to a “chance screen” and if they survive, they return to the previous scene.
I have tried using get_tree().get_edited_scene_root.filename and keep getting “nil” errors. What’s a best practice for this? my scene changes are handling fine except for this one.
I am trying to use a global variable to store the scene using my door class in each room. I only have three rooms loaded at any one time so I don’t need a complex level-change system.
Singleton ## hold current scene if in kill_screen
``` var sceneJar = preload("res://assets/TESTROOM_00.tscn") ```
Then the “update” in each room, running at ready:
``` func room_store(): _currentRoom = get_tree().get_current_scene().get_name() Global.sceneJar = _currentRoom ```
Then the “kill screen” function that should reload that room but fails to do so, because i keep getting errors: (which i don’t get, because i use this method with everything else) Note: my Global variable IS updated at the ready here.
``` func _ready(): _escape_dest = Global.sceneJar func escape(): var _free = load(_escape_dest) var _free_me = get_tree().change_scene_to(_free) ```
I keep getting Resource not found errors but the filepaths it is showing are accurate. What is happening? Why does this method work for everything and not this? It’s loading the path, getting the data, it’s just not connecting the scenes.
Also: sorry if this question is common. I searched and kept finding deprecated answers.