playMaker

Author Topic: Making a solid database and utilizing data from it - advice needed  (Read 2628 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Hi all,

time came to optimize my game a bit since instantiate/destroy calls are making a lot of GC calls and it's about time to address that.

I was happy when nested prefabs came, but in the long run, it creates more problems when you intend on pooling stuff (which is neccessary for my game) since only the parent is pooled, all the children belonging to it are instantiated as usual.

I have two issues to address.

Issue #1

Enemies have multiple children which have their exact default local position and their default state (active/not active). So, for the enemy of type Provoker (in the image below) i have the following:

Enemy Name: Provoker

Child 1: Light
Child 2: Light2
Child 3: ProvokerGunpoint
Child 4: JetAnimation
Child 5: EnemyTag

Child 1 Position: x, y, z
Child 2 Position: x, y, z
Child 3 Position: x, y, z
Child 4 Position: x, y, z
Child 5 Position: x, y, z

Child 1 State: Active/Not Active
Child 2 State: Active/Not Active
Child 3 State: Active/Not Active
Child 4 State: Active/Not Active
Child 5 State: Active/Not Active



So when i spawn the enemy named provoker, fsm on it should get it's name and then spawn children with appropriate position and state.

Issue #2

Second issue is similar to first. Squadrons are groups of enemies which i handled relatively easy with nested prefabs, i just dragged and dropped prefabs, saved them under SquadronNameX prefab and that's it. But, unfortunately, these need to be spawned so using nested prefabs is kinda off.



So i meant of collecting all the data i need (which will be a long and tedious process by itself) and then what? I can store them in some data structure, but i don't know what would be the most suitable, internal like arraylist or external in a script.

The way i'm doing things now is horrible since i have few hundred of these with 5-10 enemies in each. First i need to spawn all enemies one by one and assign a variable for them



Then i need to manually set position for each one of them



It's tedious to do and there's A LOT of space for error. The preferred way would be a structure to draw data from, like get name of the squadron > number of enemies, if name of Squadron is NameX, spawn prefabY, assign positionZ, repeat until finished.

What can you recommend? Hash tables, arrays, huge scriptable object, json, xml?  I'm quite confident in scripting lately, for the first time i see this maybe more viable in script then with fsms, bit i'd like to stick to fsms completely if possible.

P.S.

Not to mention that maintaining the other enemy systems with their data (HP, speed, loot and so on) is beginning to feel real tiresome by using local (per fsm) data, i'd like to organize that a bit better too.

There's some assets like bg database and gamedata editor, i guess they're worth checking out...
« Last Edit: January 06, 2020, 05:45:04 PM by krmko »
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Making a solid database and utilizing data from it - advice needed
« Reply #1 on: January 08, 2020, 06:35:37 AM »
Well, i found the solution.

I was having a tough time deciding between Game Data Editor https://assetstore.unity.com/packages/tools/visual-scripting/game-data-editor-18480 which i used before, but is quite expensive and i had some good and bad stuff with it and BG Database https://assetstore.unity.com/packages/tools/integration/bg-database-112262 which is relatively new. Both have Playmaker support (actually, only database management assets that have it on asset store). I opted to try out BG Database, which is also half the price of Game Data Editor.

After the initial setup which takes a bit of time, but is not complicated due to good manual (google sheets api, access, tokenization and all that boring stuff) i managed to set up a database. You can either export data from the database editor in unity, or import it. I find that the best workflow is to setup fields in the integrated editor, export, fill out the data in the spreadsheet then import it back.

And now the most magical thing. There is a Playmaker action generator that creates actions related to your tables and fields.



The next best magical thing is the one i was afraid of. What if i decide to put another column in the table and recreate the actions, will the existing actions be overwritten along with assigned variables? No! All the existing actions are replaced with new ones with the existing variables and assignments intact.

Of course, if you want to use prefabs in your database, you need to enable the addressables. For now, in editor (we'll see builds), everything works fine, but it's another layer of work which needs proper handling since you can use addressables by their location (which can easy break things) or by GUID (which is a drag because it's not quite human readable). Using addressables means you can't go below 2018.3 unfortunately, so you'll have to upgrade if you didn't.
Available for Playmaker work

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Making a solid database and utilizing data from it - advice needed
« Reply #2 on: January 08, 2020, 07:24:13 AM »
Hi,

 excellent, thanks for the infos! I'll checl BG Database, seems very powerfull indeed!

Bye,

 Jean

rechronicle

  • Full Member
  • ***
  • Posts: 119
  • Mystvaldia
    • Indie RPG Creator
Re: Making a solid database and utilizing data from it - advice needed
« Reply #3 on: February 01, 2020, 08:15:40 AM »
@krmko what is good and bad of GDE from your experience using it? I see that you mention above that you have good and bad stuff with it.

It reminds me of the RPG Maker database which I like, not sure how it will works in Unity. I need some insight.
Thanks!

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Making a solid database and utilizing data from it - advice needed
« Reply #4 on: February 02, 2020, 01:59:52 PM »
@rechronicle

First of all, in-unity GDE editor sucks compared to BG which is like a regular sheet editing software. It's cleaner and customizable. Playmaker actions for GDE are also not good compared to BGDatabases which can be generated according to your needs. Generally, i think GDE is more oriented towards populating in sheets/excel, and the inspector is kinda clunky when you have a lot of data compared to BG.

Available for Playmaker work

rechronicle

  • Full Member
  • ***
  • Posts: 119
  • Mystvaldia
    • Indie RPG Creator
Re: Making a solid database and utilizing data from it - advice needed
« Reply #5 on: February 03, 2020, 08:57:01 PM »
Cool, thanks for the insight!
I can't agree more that using the inspector interface to do everything is kinda not good.

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Making a solid database and utilizing data from it - advice needed
« Reply #6 on: February 04, 2020, 02:06:36 AM »
Holy cow. I had no idea that pooling still instantiated any nested prefabs  :o

Maart

  • Junior Playmaker
  • **
  • Posts: 88
Re: Making a solid database and utilizing data from it - advice needed
« Reply #7 on: June 17, 2022, 06:49:18 PM »
I'm also using Bgdatabase and its awesome. Support is great as well