playMaker

Author Topic: Need advice on data driven design  (Read 3251 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Need advice on data driven design
« on: November 03, 2017, 07:40:45 AM »
Hi guys,

A while ago i had a suggestion for the option to export/import global variables into a spreadsheet for easier editing. Jean and Djaydino were appaled by the number of global variables i use at the moment (more than 800). For me, it was the most logical way to store data since i could access it from anywhere in the project. I was a beginner and i felt that using local variables is too limiting, especially when time comes to tweak things like attack or health points of certain enemies for example. Downside to that approach (besides security and naming), as i noted further down the road, is the impossibility to manipulate it in a more meaningful way than variable by variable in a closed Playmaker environment. Besides that, local variables that don't draw data from a data source are easy to mess up and hard to debug sometimes.

In terms of programming, i'm currently in the phase of knowing more each day, but aware that i actually have more and more to learn. As a method of learning, i decompiled a lot of stuff made in Unity by opening .dll files with Resharper. I noticed that majority of games use JSON for data storing (with XML as the second most used format). I also bought Easy Save as a very praised solution which uses neither XML nor JSON, but claims to be faster than both (tho i don't care about the fast part, easy got my attentiom) but i don't know how easy is to edit those files since they are in their own enclosed binary format. They have their own editor, but that seems as handy as editing 800 globals in Playmaker (not handy at all ;D).

Why am i asking this now? I'm starting to bump into limitations. The way i work has 0 reusability and making things interesting and with variety is starting to take too much time copying and pasting the same things over and over to get a sense of controlled randomness.

The game i'm working on is an endless shmup and i want to be able to store everything and just call it as needed.

I want to create an enemy that will draw an image, flying pattern, shooting pattern, hp, attack points, armor type, bezier path points and everything else from a data structure in the format that is easy to store, read and edit. Furthermore, i want to be able to easily make subsets and combinations of data. As far as i have seen, for something like that i need multidimensional arrays (probably) and JSON seems the best suited for something like that.

One last thing i need is the advice on most painless way to refactor the existing FSM's and stored global and local variables (exporting and rearranging to empty data structures).

Any advice is more than welcome. I attached a dummy basic data structure of how enemy objects i imagine to work like, it's basically like deriving classes and adding methods.









« Last Edit: November 03, 2017, 07:42:28 AM by krmko »
Available for Playmaker work

Dakk

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 21
Re: Need advice on data driven design
« Reply #1 on: November 03, 2017, 12:15:41 PM »
My quick advice which you may already know:

-Don't use global variables unless you absolutely have to- it will save you a lot of time and pain to just follow that rule- I chose to learn the hard way.  Except for a few cases- there is almost always a better design pattern than using a global variable.  I only use them to define my system controller game objects and a few other things.
-Learn and use set fsm var actions to pass data from different fsms- need to tick the "inspector" attribute for the var so they are accessible.
-For instanced game objects you can set and store the data you need on the prefab itself- just add some public vars to a simple script on the prefab.  I've found that is the best way to keep data that is associated with an obj instance.
-Data Maker/Array Maker has a ton of options to load and save data- I read huge .csv of data into my game for inventory/unlockable system then store it in arrays for use- then apply to my game objects as needed- works great (except on UWP).  For tuning and balancing after the AI tests the game overnight I write out a huge .csv which I can analyze conveniently in excel.
-Templates and Run FSM are powerful- great way to keep your fsm's smaller and re-use fsm's. This feature doesn't seem to be widely used- but it is very useful- a bit hard to debug if you nest several templates and there are a few editor display bugs- but still worth exploiting.
-Easy Save is great!  I use it for saving all user data, and also offline in the editor to save out my level data, then load these files at run-time.  Works great, Joel is a pro and very dedicated to support.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Need advice on data driven design
« Reply #2 on: November 03, 2017, 01:15:36 PM »
Hi,
Indeed json or xml is a good way to go.

You can check out this video (and the other 2 parts) to get familiar with datamaker :


To refactor depends on your setup it's hard to tell.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Need advice on data driven design
« Reply #3 on: November 03, 2017, 04:39:31 PM »
Luckily, globals can be opened in nice readable spreadsheet format, easily converted to xml, and be used to populate hash tables. Also, xml can be easily edited by ms xml editor. Regarding that, easy save 3 is in beta and is not supporting xml and json until full release comes out (unfortunately, it won't be backwards compatible with es3) and frankly, by watching djaydino's tutorials, i don't think i feel quite comfortable yet with xquery nor i have that amount of data to find that complicated setup useful in the long term.

So, my question is, are hash tables fast and good enough way of storing data? They're quite convient for me and can be easily manually populated.
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Need advice on data driven design
« Reply #4 on: November 04, 2017, 07:03:52 AM »
Hi,
Hash tables should be as fast as arrays,
But good enough depends on what you are using them for.

xml/json would be ideal i think.
May make a new project with datamaker and play around with it so you can understand it better.
There are also some samples included with the package.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Need advice on data driven design
« Reply #5 on: November 04, 2017, 02:11:22 PM »
As far as i have read, they're basically the same as getting an array item by index number, so that's cool. I'm storing variables and references, simple data types mostly split into several hashtables, so it should be fast as hell since it takes a lot more complicated FSM's to avoid working with globals.

Great idea, i'll play a bit.
Available for Playmaker work

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Need advice on data driven design
« Reply #6 on: May 04, 2018, 05:23:58 PM »
Hey Krmko! :D

Just wanted to follow up since its been a few months and see if you've discovered/been working in a new way since posting this topic? I've been slowly shifting over into the same type of workflow and am totally looking for pointers! :D

-craigz

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Need advice on data driven design
« Reply #7 on: January 07, 2020, 06:40:13 AM »
Hey Krmko! :D

Just wanted to follow up since its been a few months and see if you've discovered/been working in a new way since posting this topic? I've been slowly shifting over into the same type of workflow and am totally looking for pointers! :D

-craigz

Hah, sorry i missed this.

The more i progress in the project, data management is getting more and more complicated. I'm not using as much global variables as before, now it's mostly global events with local variables and lots of managers with local variables. But storing data is still a problem, lots of global variables are shit for maintenance and you can make a mess if you name some of the local and global variables the same and assign a local one instead of a global one, there's no chance you'll ever find where you made a mistake.

Few months ago i worked on Statfetched, a platformer which was done in c#, no Playmaker and we used Game Data Editor in it, a cool asset which uses google sheets to draw data from (and it has Playmaker actions). Another one that caught my eye is BG Database, which works the same way and has Playmaker actions too. By using spreadsheets you can keep track of all data in an organized manner, avoid using global variables and analyze and modify it as needed. Instead of storing similar stuff and variables across fsm, you keep everything in one sheet and get it as needed.

Still haven't done it since it takes time, but i think it's the way to go in any fairly complex project.
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Need advice on data driven design
« Reply #8 on: January 08, 2020, 06:38:25 AM »
I opted for BG Database, a fine tool. More on it here: https://hutonggames.com/playmakerforum/index.php?topic=21528.0
Available for Playmaker work

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Need advice on data driven design
« Reply #9 on: January 10, 2020, 09:37:08 AM »
If you are into spreadsheets + and using Playmaker you can use GameDataEditor.  The dev has stopped updates on it and only provides bug updates.. but it does have playmaker and google drive support and works quite well I think!

edit

saw this post:  https://hutonggames.com/playmakerforum/index.php?topic=21528.msg94544#msg94544 and realized BG Database looks like a better solution if only because of the playmaker action generator
« Last Edit: January 10, 2020, 09:49:00 AM by PlaymakerNOOB »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Need advice on data driven design
« Reply #10 on: January 11, 2020, 06:45:59 AM »
Yeah, it's awesome. Way better than game data editor imo.
Available for Playmaker work