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

Most efficient way to store old data

Discussion in 'Scripting' started by tawdry, Nov 17, 2015.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Hi
    So upon death i am wanting to reset a characters stats to 2 hours back short of continously saving the stats every couple seconds or minutes is there any other way to keep a record of these stats?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    I think you answered your own question by definition of the problem!

    So, No.

    The only way you could do this would be to design an expression that let you "subtract two hours worth of stats progress" but in all but the most trivial game (think "Progress Quest"), that has no meaning.
     
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Yea i realised i answered my own question i could just save every 5 minutes even and i only really need exp point and level so hardly a huge resource drain just have to figure out how to save now haven't exactly explored that area
     
  4. novashot

    novashot

    Joined:
    Dec 12, 2009
    Posts:
    373
    assuming your player data you want is in a class called player...

    Code (csharp):
    1.  
    2. Player saveState;
    3.  
    4. void Save(){
    5.      saveState = currentPlayer;
    6. }
    7.  
    8. void Load(){
    9.      currentPlayer = saveState;
    10. }
    11.  
    just make a copy of the player data at whatever state... or make a list of them to have more options.