![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | thewraithmod |
I have an “overworld” where the player can walk around and find dungeons/towns. When a player is overlapping one of these locations they have the option to enter them. Doing so causes them to switch scenes (to the dungeon scene where a different player scene is used, for example)
When the player exits the dungeon I want them to be able to return to the “overworld” with everything staying saved/the way it was before they entered the dungeon.
In the “player_overworld.gd” script, I call the save_scene() function from the Global.gd singleton.
func _input(event):
if event.is_action_pressed("space"):
GLOBAL.save_scene()
this is my code for saving the overworld scene and entering a dungeon:
func save_scene():
var root = get_tree().get_root()
saved_scene = root.get_child(root.get_child_count() -1)
get_tree().get_root().remove_child(saved_scene)
var new_scene = temp_scene.instance()
get_tree().get_root().add_child(new_scene)
get_tree().set_current_scene(new_scene)
This method is in a singleton called “Global.gd”
The variable “saved_scene” is also in that script.
Whenever this method is run I get a list of errors that all say:
0:00:08:0751 - Condition ’ !area_in && !E ’ is true.
I assume this is somehow related to the fact that the player_overworld scene is an Area2D node that checks for overlapping areas every frame. I do not know how to get rid of these errors and I am wondering if there is a better way to do scene switching and returning. I just want to have an overworld scene that is persistent and can safely be switched.