playMaker

Author Topic: Array Maker + Easy Save 2; "unique tag" issue  (Read 6065 times)

copenhagenjazz

  • Playmaker Newbie
  • *
  • Posts: 10
Array Maker + Easy Save 2; "unique tag" issue
« on: February 04, 2014, 05:37:59 PM »
Hi there

I am trying to get a rudimentory save game system up and running using array maker and easy save 2.

So far I have managed to create a system where you indeed can save and load the position of an object. My plan is to make this Save/Load-FSM a template and copy it to whatever objects I want to save and load.

However the issue is that I do not really know how to assign a unique tag to an object. If I duplicate the current object and save the position of just one of them the rest will also load the position as the one I had selected when saving the position of said object.
I highly expect this to be because of the lack of unique tags.

How can I assign a unique tag to an object and individual prefabs of this object?

Please have a look at my setup;



Thanks in advance :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #1 on: February 05, 2014, 04:23:00 AM »
Hi,

Basically, you have to make it up.

Use the game object name ( action "Get name"), and compose it with another keyword using "build string" action.

Bye,

 Jean

 


copenhagenjazz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #2 on: February 05, 2014, 06:00:45 AM »
Thanks for the reply Jean :)

I am not entirely sure exactly how to do it but will give it a shot when I get home from work tonight.

I have also considered using the Unity Serializer plugin (http://whydoidoit.com/unity-serializer-version-2-0-features/) but opted not to do so as some people experience inconsistencies. Also I would have no way of debugging it properly or to understand what is going on so to me the option of using Playmaker and Easy to Save 2 seemed like the more "proper" way of doing a savegame system.

Thanks again and I will let you know how it goes :)

copenhagenjazz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #3 on: February 05, 2014, 04:17:42 PM »
Hi Jean

Alright I got it semi working.

This is what I did;

1; Found and stored objects original name
2; Created random integer (just a number between 0-10000) variable
3: Converted the integer to a string variable
4; Combined original name and string using the "Build string" action and saved that to a "Object Unique tag" variable
5; Saved unique tag variable to array for use the next time the scene is loaded



This works well with multiple objects when the scene is running. I can store the transform of several duplicates and they do no longer share the same save positions. Thats great :)

However; At step 5 (in my previous walkthrough) I have a massive problem. I cannot wrap my head around how to assign the stored unique tag to the right object the next time the scene is loaded. Currently every object receives a new unique tag every time the scene is restarted which of course ruins the save functionality.

Do you have any suggestion as to how to do this?

Thanks so much for your help and time - you are doing an awesome job :)
« Last Edit: February 05, 2014, 04:25:40 PM by copenhagenjazz »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #4 on: February 06, 2014, 03:19:47 AM »
Hi,

 Indeed, that doesn't work like that. the Id you generate has to be reproduceable always.

 so using the game object name is good, then you would for example add "/Transform" to i so that you can seave different values for the same gameobject. So your key would be

"[GAMEOBJECTNAME]/Transform"

If, your game object names are not unique, then you should edit them so they are, and if you are dealing with prefab you instanciate, then you have a problem :) and you should find that make them distinct in your game and play with this, but that's already down to how you actuall build your game...

Bye,

 Jean

copenhagenjazz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #5 on: February 06, 2014, 04:47:10 PM »
Hi again

Thanks for your reply Jean - much appreciated :)

Ok so after much investigation this week it seems like unity serializer is the way to go. It seems almost too simple and straight forward to use and I just really hope it wont bite me in the butt further down the road :P I guess Easy save 2 can still be used for storing and loading from arrays and hastables but for now I will rely on serializer as my main save tool.

Thanks

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #6 on: February 06, 2014, 05:12:05 PM »
How about another option? Create a FLOAT or Int Global Variable called "ItemID" and then add 1 to it anytime you create an item. That way everything is in a logical order and unique. If you have multiple item types, you could do have a string header like Object00, then make a new string with that number, so then its Object01, Lamp00, Lamp01, Lamp02, etc.

copenhagenjazz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #7 on: February 06, 2014, 06:38:31 PM »
mweyna; Hmm but how would the naming of the objects happen? I mean for this to work ideally the objects should be given a unique name the instance I add the to the scene hierachy then. And I do not really see how you can do that with playmaker - ?
Quite honestly I do not trust myself to check the naming of all objects in my scene. Not only will I in the end have literally hundreds of objects to manage but I am also intending to use nested prefabs (http://framebunker.com/blog/poor-mans-nested-prefabs/) and I do not think I would be able to control the naming of these.

I have been doing quite a bit of research on the matter over the past days and saving and loading a game state seems to be the dark art of unity :P

I will give Unity serializer a go over the weekend and let you guys know how it Works out :)

miketolsa

  • Playmaker Newbie
  • *
  • Posts: 22
  • Just love playmaker !!!
    • 4Buffs Productions
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #8 on: August 31, 2015, 02:39:26 AM »
I think this year old thread would saved my life in my current project .....

thanks !!!!

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Array Maker + Easy Save 2; "unique tag" issue
« Reply #9 on: September 03, 2015, 12:53:46 AM »
So the way I handle my prefab issues (given I am spawning high volumes of prefabs all with new names) is upon Creation, the object writes itself to two Arrays with it's prefab name, and then it in-game name. I save both as well as any stats on that item (Bool, Ints, etc). On Load, I use the prefab name to determine what to spawn, then load the corresponding String for it's proper object name, rename the prefab with that string, and then load all those stats onto that object. It's a complex FSM but so far for me, has got the job done that all my units can maintain their unit stats and names without being destroyed during save/load.