How can I move a character from one place to another through a door?

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

I’m making a simple and miniscule 2D top-down game just so I can get the hang of things.

How would I be able to make a door that transports a player from an overworld into and interior once interacted with? One of those classic “fade to black” kind of doors that play a short animation before teleporting the player would be just fine. Something like this:

I think I already know how to make the animation for the door to play after the player interacts with it, but I have no idea on how to make everything before and after it happen.

I know that this is a simple question that even a toddler would know the answer, but I would be grateful if someone were to teach me how to proceed.

:bust_in_silhouette: Reply From: Gluon

You would need something to trigger the fade, so either have an area2d or a collision box around the door so you know when the player has stepped there.

In that scene you then need a canvaslayer and create a sprite as a sub node which will just be a black box. The create an animation player on that sprite with the alpha set to full at the start and then off at the end. Then when you detect the player going into the area2d of the door you can play the animation and a black box will fade in to the scene blocking everything else beneath it. After that you can just transition to the next scene where you want the player to be or move the player to a position node if it is in the same scene. If you then do the same animation in reverse you can fade back in if you want. Hope this helps.