Playmaker Forum

Playmaker Help & Tips => Playmaker Tips & Tricks => Topic started by: krane on January 30, 2017, 07:35:27 AM

Title: Persistent data-- best practices?
Post by: krane on January 30, 2017, 07:35:27 AM
I'm getting really confused about persistent data (i.e. across scenes).
On one hand I hear to use global variables to store data (e.g. "coins collected").
On another hand, I hear to use a local variable tied to a don'tdestroyonload object.
On another, I hear to use save files and load it in each scene load.

What are best practices for different types of data that might persist across scenes?
thank you
Title: Re: Persistent data-- best practices?
Post by: marv on January 30, 2017, 08:11:29 AM
I consider myself still very much a beginner (though I've been at it for about 2 years now) so I can't give any definite "best practices". What I've come to find, though, is that it depends a lot on how you structure your project and what works best for you in any given situation.

I actually use a mix of different methods for it, depending on the data I need carried over.

I use globals for basic variables that get accessed a lot, because it is easy to add in a state...
... for example an xml file that carries all the data on prerequisites for random events to fire

I use dontdestroyonload objects with arrays/hashtables that carry larger amounts of data that get populated dynamically
... every event has its on xml file with its contents, what texts/images to display etc. couldn't do that with either local nor global variables

And I use easysave save/load for the game settings and new game setup, just because I was getting into es2 at the time I made the settings/game setup menu... still works perfectly fine.

I think the important part is finding a method that works for you and your project and stick to it. I've mostly gone with a focus on ease of access during game creation and so far I've seen no downside in regards to performance or whatnot.

But as I said in the beginning, still very much a beginner imo, so take with a grain of salt.
Title: Re: Persistent data-- best practices?
Post by: krmko on January 31, 2017, 04:55:19 AM
Yeah, i think it depends on the scope and type of project. I'm planning to use global variables only, i don't think i need more for a sidescrolling shooter. On the other hand, if you work on an MMO that stores your location/loot/stats and loads of other data then something more serious should be used, i guess xml is the weapon of choice these days.
Title: Re: Persistent data-- best practices?
Post by: HelenKelly94 on April 23, 2017, 06:29:36 AM
Marv you don't know how useful that was for me. Thanks so much!