Save scene state

Hi guys,

i’m new to unity and i’m trying to make a physics based drag and drop game, where the user drag items around the screen and then press play to make the items interact. If the user does not like the way the items interact, there is a reset button that allows the user to edit the items position. At this moment that button only restarts the scene, making me lose every object tha was already placed on the screen. I want to know if there is a way to save the scene before pressing play, so that when reset is pressed the game came back to that state.

I think i could do that by adding a script that saves the position of each item, and then when reset is pressed, instantiate each of that items to the original position, but it seems like a rough solution.

Any idea will be appreciated

Thanks

It’s actually a quite appropriate solution. There is nothing to make a snapshot of the game at a given time, so you have to code the save process yourself. On a single scene, store the positions as you said, accross scene you’ll need to use static vars, DonDestroyOnLoad or PlayerPrefs, among other ways.

If you want players to be able to save and load these scenes too then PlayerPrefs is your best bet. I would look at this extension for player prefs which lets you use vector3 among others. unifycommunity.com

Thank you so much for your answers, unfortunatelly i can’t vote your replies, but thumbs up. i’ll try all of them and see wich one works for the best.

Have you tried “Time.timeScale” ?