Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making game Save/Load states

Discussion in 'Scripting' started by ddulshan, Jan 17, 2015.

  1. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
    Well, as the topic says I want to know how to make a game's Save and Load functions. I have no idea how to do this one!

    I need help doing this and I'm familiar with Java.

    Thanks in Advance!
     
  2. shadow-river

    shadow-river

    Joined:
    May 29, 2013
    Posts:
    63
  3. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
    Thanks. I'll read these and reply back.
     
  4. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
    Well I read those, the first Unity guide doesn't actually say how to do it and the UnityAnswers one is too complex for me to understand since I'm a Beginner and it seems like something to load a previous scene.

    Anyway. Please help me step by step explaining stuff. As for this is my first game I only need AutoSave at some points and when player start the game next time, he gets a option "Continue Game" to continue from the last autosave.
     
  5. shadow-river

    shadow-river

    Joined:
    May 29, 2013
    Posts:
    63
    what data are you wanting to save, what data are you wanting to load are you wanting to save the players position, the players score, how many levels/scenes are you using cause you'll have to keep track of those so you can load the right one .
    in one of my games I used playerprefs to keep track of the players high scores and also for when the player enters there name into a high score slot they don't need to retype there name if they get another high score straight after.

    sorry for being vague again, but if you can give me a little more info I can try and help you a little better.
    I'm still learning myself so there may be a better way but ill do what I can.
     
  6. TheSniperFan

    TheSniperFan

    Joined:
    Jul 18, 2013
    Posts:
    712
    If you just store a few variables, use PlayerPrefs. If you store a lot, use this.
     
  7. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
    @TheSniperFan : Ah dammit I hate reading so much. But I'll go through it.

    This is a simple horror game. The player needs to progress through some terrifying scenes. Its FPS. Well I just need to know how to Auto-Save the games at certain points, like if the player steps in a certain Trigger(Can saving done like that? Stepping in a in-game trigger?). Since its auto saving it overwrites the same save. And when the player plays the game for the first time, the menu only contains "New Game, Options and Exit" options, and when a AutoSave is done while playing the game a option appears in the menu "Continue Game". Well that's all I can describe about, what else you need to know? @shadow-river.
     
  8. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
  9. shadow-river

    shadow-river

    Joined:
    May 29, 2013
    Posts:
    63
    what are you using C# or javascript. theres no easy way to do it when you save you need to save individual variables that you want to use again. are you using an inventory system cause you'll have to save that info as well. I can come up with an easy way to save and load your players position ( wont be straight away) but you'll have other variables in your scripts you'll want to keep track of. like before you reach check point 1 you might have an event happen then you tern a Boolean variable to true to let you no its happened which in tern starts an other event later when you reach that check point you have to save that variable to a playerpref so that when you continue the game, the game knows that you've already passed that point and can continue on. there's a lot of things you have to consider.
    how have you got the menu set up are you using 4.6 ui or the old gui system.
    it might be best to try the plug in first.
     
  10. ddulshan

    ddulshan

    Joined:
    Mar 16, 2014
    Posts:
    190
    Well, I'm using Unity 4.5. And Java is I'm most familiar with. And you mean I have to add a Bool to every event trgger so it can be marked as happened or not? And I'm not planning to make a Inventory. So the items are accessible through the Numbers on the keyboard. And player finds items throigh out the game when progressing.@shadow-river.
     
    Last edited: Jan 18, 2015