Transition scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Renna048

I would like that when the player got close to the door and pressed a button, it would play an animation and it would change scene

func _process(delta): if input.is_action_pressed(“ui_accept”): get_tree().change_scene(“res://path/to/scene.tscn”)

You could do that with a Tween. In your process function instead of immediately calling the change scene function you could call an intermediary function… something like animate scene change:

func AnimateSceneChange(pathToScene: String) -> void:
    'Tween code here...

I notice you’re using 3.4, if you’re willing to upgrade to 3.5 you’ll get access to the new SceneTreeTween class which I personally think is a much better and more logical implementation. See the docs here.

But if you prefer to stick with 3.4, you can easily connect the Tween All Completed signal to another function which would finally call the Change Scene function. Hope this makes sense.

dacess123 | 2022-08-16 19:02

:bust_in_silhouette: Reply From: SnapCracklins

I actually am working on a project where I’ve done exactly what you’re doing (almost: a door animation in my case before the scene changes). You can easily achieve this with a signal from your AnimatedSprite (or whatever). Let’s say you have a door animation called “open” and one for “shut.” Then just have some logic check which animation it is and then change the scene when the animation ends. NOTE: if you are going to be copying/instancing this node, make sure to connect the signal before saving the scene so you don’t have to reconnect constantly every instance.

func _on_Animated_Sprite_animation_finished(anim_name):
    if == "open":