I can save and load but every entity is restored to the same position

Hi! I have this problem stated in the title. I’ve tried to debug it the best as I can and found that when the state is captured in CaptureState(), it captured all the different positions correctly, but when I use SerializableVector3.ToVector() it defaults to a single position to the same positions as all the other saveable entities. Here is the code for SaveableEntity and SavingSystem:



Please ask any questions to clear up confusion.

Thank you!

I think it’s the uniqueIdentifier. You have cleared your uniqueIdentifier to “” and now that is causing the system to load the same value for all. That is: all your entities report their uniqueIdentifier as “”, so the same value is saved and loaded for all.

Edit I’ll be a little less vague: The SaveableEntity generates a unique identifer and stores it in uniqueIdentifier. This is all good, but the saving system does not read that value. The saving system gets the unique identifier from GetUniqueIdentifier(). In your code, you are not supplying the generated unique identifier. You are supplying “”. So all of these SaveableEntity's are reporting their unique identifiers as being “”

Should be this

public string GetUniqueIdentifier()
{
    return uniqueIdentifier;
}
2 Likes

Ohhh, I see. I just needed to change it to return uniqueIdentifier. Thank you so much!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms