- Home /
The player goes through a door and change scene. If I come back, how can I have the player appear where it left off?
I am designing a game where the player is going through doors to solve a puzzle to open up doors further down the game. But the player needs to go through a door, solve the puzzle, and come back out through the door it went through so it should spawn a that door. However, the player keeps spawning at the beginning of the level.
I've tried using PlayerPrefs to assign manual spawn points to spawn from but it doesn't work. Any help? I've been stuck at this for too long :(
this is one of the most common questions i have seen in unity answers, you just need a way of persisting data, playerprefs is an option, why is not working?
Oh Sorry, I tried searching but couldn't find a solution that worked for me.
I have triggers on each doorways in all the scenes that lead to another scene. I use a trigger to call a different scene if "E" is pressed while in the trigger.
So I saved the current scene build index before changing the scene, and when you get to another scene, the game manager object references the scene index to the possible spawn locations and their assigned scene index. Then moves the player object to the spawn location during the "void Start()" function.
Answer by Vollmondum · Mar 21, 2019 at 02:27 PM
You need to check PlayerPrefs in void Awake(), and Instantiate in Start()
Your answer
![](https://koobas.hobune.stream/wayback/20220612193953im_/https://answers.unity.com/themes/thub/images/avi.jpg)