Loading child objects

Discussion and help for Easy Save 3
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Loading child objects

Post by Notso »

I read a few posts about similar, and I am still having an issue.
(I did manage to fix my other about the in scene items we were dealing with, and setting an ES3type on the collectable scripts I was able to save ammo counts on boxes and weapons dropped)
I create a list at start where all AI will sit (this is the list I save). They only get disable and never destroyed. Once killed they go ragdoll and turn off the animator.
My enemy has an empty parent (like most setups)
Under this I have an "AI" child that has everything on it, animator, states, AI controller etc...
I set the parent as an ES3prefab, set the AI child with an ES3gameobject checked to save transform and the AIcontroller script. On new game, I mess with the AI values health, body damage etc.. after saving I scan through the save file, the values are there and saved correctly.
However on load the AI is back at the initial starting point, and the values are back to default. I tried enemy = es3load and then just a loadinto (without the enemy = paart) but both are the same.

Is there something I am missing? The enemy do go into disabled mode if the player is not nearby (and even the animator gets disabled too if close but not in visual range) but I believe you said even if disabled it should still find the values and change them.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading child objects

Post by Joel »

Hi there,

Unfortunately it's not possible to understand what is happening without being able to see your project. Please could you create a new project containing only Easy Save with a very simple scene which replicates your issue and send it to me on moodkie.com/contact along with your order or invoice number and instructions. It's important that this is a new, simple project rather than a cut-down version of an existing project so that I can isolate the issue to Easy Save.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Loading child objects

Post by Notso »

I wIll have to come back to this. I am having a similar issue with my doors as well.
A parent with the door script and is the frame, as child that is the door, it is not saving the childs transform open values even using the es3prefab on the parent and es3gameobject on thje child with transform checked.

Side question, I have a prefab with an es3prefab script on it and it keeps assigning the same ref # when I drag a new one in the scene so now I can't save......ArgumentException: An item with the same key has already been added.

Now these already exist so yeah, I can add the save destroy to them, but will they be same if instantiated?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading child objects

Post by Joel »

An ES3Prefab Component is supposed to have the same ID for all instances of that prefab. I've not seen the error you're experiencing, please could you post the full error with stack trace?
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Loading child objects

Post by Notso »

Not sure what the error was referencing, I removed all scripts rom all objects and started over with ES3prefab and savedestroy and it seems to have went away.
Anyway, My door is in parts, a parent with the scripts on it, and a child that is the "interior door" that actually opens and closes. I put a es3prefab on the parent, and an es3gameobject on the child and check the box transform, nothing else. I hit save then pause the game, open the file and I find the key "DOORS" and look for "interior door" name, find it and then scroll down and none of the transforms under that name have the current transform values. (and loading the door is still in the default position. I do a onsceneloaded before I load saves to make sure everything is at default before changing values)
Am I using the es3gameobject correctly?
I am not sure the es3gameoject is doing what I need it to do? I had a similar issue on another objectt I added the es3Go and checked nothing but it saved everything (all transforms etc...)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading child objects

Post by Joel »

Hi there,

Just to check, are you adding the ES3Prefab by right-clicking and choosing Easy Save 3 > Enable Easy Save for Prefabs? You should never directly add the ES3Prefab Component and should do so as described in the documentation.

Also as mentioned previously, adding an ES3Prefab and ES3GameObject doesn't save an object, it just tells Easy Save how to save an object. How are you saving and loading your object?
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Loading child objects

Post by Notso »

Yes, I am right clicking (as mentioned it saves it in the save file, I can find it I only do 1 door at the moment so easy to find it)
I am saving the same way as the prefabinstances...I have tried both
(adding only the interior door child)

Code: Select all

public  List<Transform> doorValues = new List<Transform>();
Also

Code: Select all

public  List<Vector3> doorValues = new List<Vector3>();
and
(adding only the parent object with es3prefab from right clicking in assets folder)_

Code: Select all

public List<GameObject> doorValues = new List<GameObject>();

Code: Select all

ES3.Save("Doors", doorValues);
Then tried

Code: Select all

ES3.LoadInto("Doors", doorValues);
and

Code: Select all

doorValues = ES3.Load("Doors", doorValues);
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading child objects

Post by Joel »

Do you have Save GameObject Children selected in Tools > Easy Save 3 > Settings?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Loading child objects

Post by Notso »

Yes, of course (just checked to be sure)
But as I mentioned, I can see it saves the transform but the default and not the current one when open.
So closed the Y = 0 and open the value should be around Y = 89 but.94 but that value is no where in the save file under the key DOORS, and there is only 1 door I am testing so easy to scan through all the transforms (and using sublime text I also FIND and 89 does not show).
I found a script you wrote for someone else about saving position using vector3, going to try that just to see if it works. You give it a separate guid and save vector3.
OK so I guess my issue was I did not understand the Quaternion is -1 to 1.
I managed to save using
public void OnDestroy()
{
ES3.Save<Vector3>(guid, transform.localRotation.eulerAngles);
}
Getting the proper value I can actually see is correct.
Now how to load that value back?
Seems I can't use vector3 or quaternion (correctly) to get the script error to go away on the load method.
Also if you could help a bit with how can I just save these values in a list and on save, update them to current value then save it.
I really don't want it writing to the save file everytime they open or close a door. Rather just save the values like in a for each loop maybe?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading child objects

Post by Joel »

Please could you show me the code you're using to load and the script error you mentioned.
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply