Cutscene that plays once on level transition

Godot Version

4

Question

So I have a base for a game right now where I have levels/screens that can be transitioned between. This means that the player can exit a screen and then go right back into it. I am working on trying to set up little cut scenes that can be played the first time the user enters the next screen but will not play then. Just not really sure what the best option would be as I have tried multiple solutions that have been less than ideal. I would like to build some sort of reusable component for this.

Means fade in/fade out between scenes?

A bit more than that, sorry, should have clarified. For example maybe when the player first transitions to a screen I want the player character to move around and pick something up, or have something in the environment come crashing down before returning control to the player.

I found a solution, someone can feel free to let me know if there is a better one. I have created a “Cutscene” scene that has an animation player and a script attached to it that will mark whether some cutscene has played or not in a singleton. I than instance this cutscene in my level, and create whatever animation I want. My script attatched to my level/screen object will check if the cutscene has played on ready, play it if it has not, and otherwise call my usual function positioning the player in the level and freeing the cutscene instance from the tree. The problem with this is there is a brief flash of the cutscene objects before it is freed, although I will probably introduce some sort of fade transition to account for this.