Search Unity

The simplest save/load method for this game?

Discussion in 'Scripting' started by Mystic_Quest, Mar 1, 2017.

  1. Mystic_Quest

    Mystic_Quest

    Joined:
    Feb 22, 2016
    Posts:
    47
    I am making a 2d top-down rpg (zelda clone) for my college. Random enemies instantiate with time and move towards your house etc, there is a day/night cycle, music, player has coins, life etc and can get items (I have bools for these items in other scripts that determine if the player has them or not). I also have an NPC with various stages of dialog. It only has 2 scenes main menu and a game scene.

    I want to be able to quicksave with e.g. f5 and quickload with f8. No need for many files. I want these save states to persist if the player quits the game. I want the simplest possible solution because I've finished the project and barely got time in my schedule.

    Can anyone please suggest a way to do that (besides using external plugins)?

    Also, I have been looking at playerprefs method. If I use it, do I have to get every single variable that changes through the scene? For example, player/house health, money, the tint of the screen (night/day), an array of all enemies (and say for each "enemy" set x,y,z?), all bools for all items and all the NPC dialog stages (they are bools too), animation states for chests etc and then get them for the load function? Sounds like a massive chore - is there any easier way?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    PlayerPrefs is and always has been bad for saving games. It's designed for, and should be used for, exactly what it says on the tin: preferences and settings.

    This tutorial is a fantastic primer on the best way to save and load games.