How to set the position of an object in another scene?

I hate the scene system so much

Anyways what Im struggling with is so simple yet so complicated. Basically I have a door system. It works like a legend of zelda door system. meaning that when a player exits a building the player spawns at the location of the door to the building opposed to a default area.

Ive been pulling my hair out over this one. My goal is to have it all take place in one Game manager script but the problem is referencing objects in a different scene. GetRootGameObjects doesnt really work.

Does anyone have any good tips for creating a clean script that is a singleton that can grab the components of the next scene, and set the player(a dontdestroyonload singleton gameobject) location based on a position of something in that next scene?

you can not reference gameobjects across scenes as they are destroyed on scene load. You have to “find” the object anew each time you enter a scene afaik. (Except ofc if you take those objects along with DontdestroyonLoad)

you can however implement some kind of “spawn” point system where each point has an index (could also be an enum value for better readability) so you can carry the index over to the next scene.

This can even be done without a singleton as the “spawnindex” just has to be static. Static values are kept over scene change.

One more solution approach that might perhaps work but that heavily depends on your game itself is additive scene loading. If you just want to load a small room or building you can just add this to the current scene if i remember correctly. Then you can unload that “additive” part again if it is not needed anymore.