简体   繁体   中英

Save scene in middle of game

I made a mini-game that when you near some object if the user press an specific key it changes the scene, on that scene there is an option to return to the main scene But when it return to the main scene it goes back to the original position and not on the previous position. How can i make to when the player returns to the main scene he spawns on the previous position?

Thanks in advance.

You've to store the scene currently state on a variable.

If for example you have a button that can have two states you have to store the state of the button in a variable of an object that will be marked as DontDestroyOnLoad, or save it in a file, so when you load again the scene, you have to set the scene from the information of your stored variable.

You can also set your scene (or objects than can mutate) to DontDestroyOnLoad and change deactivate them on the new scene. But this is really dirty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM