Godot Version
4.6
Question
To swap between scenes, i had a pretty simple plan. I would spawn a transition scene with a higher Z index to smoothly transition over to the next scene in the game, during the transition, which covers the whole screen, it would either wait until the screen was finished animating via await ani.animation_finished or via timer, and delete itself via queue_free().
From the Title screen
var nextScene = preload("res://Scenes/ExplainScreen.tscn").instantiate()
func _on_start_button_pressed():
get_tree().root.add_child(nextScene)
thisScene.queue_free()
to the âexplainâ screen
var nextScene = preload("res://ToGameScreenWipe.tscn").instantiate()
func _on_next_button_pressed():
get_tree().root.add_child(nextScene)
self.queue_free()
to the first transition
func _ready():
var Anim : AnimationPlayer = find_child("AnimationPlayer")
Anim.play("Screenwipe")
await Anim.animation_finished
var nextScene = preload("res://Scenes/MainGame.tscn").instantiate()
get_tree().root.add_child(nextScene)
Anim.play("PostWipe")
await Anim.animation_changed
self.queue_free()
to the maingame,
and from the main game,
var nextScene = preload("res://EndScreenWipe.tscn").instantiate()
get_tree().root.add_child(nextScene)
var Animatetime = Timer.new()
Animatetime.set_wait_time(1.5)
add_child(Animatetime)
Animatetime.start()
await Animatetime.timeout
find_parent("GOD").queue_free()
To the second transition
func _ready():
var Anim : AnimationPlayer = find_child("AnimationPlayer")
Anim.play("Screenwipe")
await Anim.animation_finished
var nextScene = preload("res://EndScreen.tscn").instantiate()
get_tree().root.add_child(nextScene)
self.queue_free()
And the ending screen does its thing.
and i have the option to retry:
func _on_retry_button_pressed():
var nextScene = preload("res://ToGameScreenWipe.tscn")
nextScene.instantiate()
get_tree().root.add_child(nextScene)
self.queue_free()
Now, each of these will work, and work fine.
But the moment it attempts returning to any previously visible screen, it stops working.
Iâve looked around for an answer in multiple different places, but the usefulness of the internet is shoddy these days.
Honestly, im stumped.
Any ideas?

