playMaker

Author Topic: life of a variable  (Read 907 times)

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
    • View Profile
life of a variable
« on: May 27, 2016, 05:53:15 PM »
I understand how to pass variables from one FSM to another. Yay! It is working. What I don't understand is how to keep the values of these variables from changing when I stop playing the game in the Unity editor.

For instance, I have a BOOL that is set to false by default. A state changes this value to true and then passes it to another FSM. When I stop the game and restart, the value gets reset back to the default value. I have tried global variables and they are doing the same thing. How do I keep these values from one session to the next?

I have briefly looked over the PlayPrefs and am not sure if these persist from one session to the next.

Help this really frustrated person achieve total world domination.

Chizzler

  • Junior Playmaker
  • **
  • Posts: 67
    • View Profile
Re: life of a variable
« Reply #1 on: May 27, 2016, 06:04:20 PM »
What you're describing is a Save System. You're on the right track with Player Prefs, they do persist between sessions. Depending on the amount of data you need to save there are better alternatives, but Player Prefs is fine for small amounts of data. You save the variable and give it a Key. When your game loads, it can get then get the variable in later sessions using that key.

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
    • View Profile
Re: life of a variable
« Reply #2 on: May 27, 2016, 06:18:56 PM »
You suggest better solutions. At this point I'm not sure how much info will be saved. Would you suggest something like Easy Save 2 to make things easier?

Meanwhile, I will try your suggestion. Thanks