I have some checkpoints that auto-saves the game. It saves a lot of data, so I get some frozen frames which makes the gameplay not smooth.
Can I do this saving task aynchronously or something similar?
Is it possible to save asynchronously?
Re: Is it possible to save asynchronously?
Hi there,
Have you followed the Improving Performance guide?
https://docs.moodkie.com/easy-save-3/es ... rformance/
All the best,
Joel
Have you followed the Improving Performance guide?
https://docs.moodkie.com/easy-save-3/es ... rformance/
All the best,
Joel
-
- Posts: 23
- Joined: Sat Sep 05, 2020 12:53 pm
Re: Is it possible to save asynchronously?
Hi there!
Yes I have followed the guide. The thing is that I save like 600+ gameobjects so a hiccup seem inevitable when you iterate over that long list and do operations on each objects.
Now the act of saving only freeze the frame for like 0.1 or 0.2 seconds so it's not that dramatic but I would like to get rid of that if possible.
Running a thread with async await is tricky because I sometimes save gameobjects or transforms, and I can only do this in the main thread.
Also in order to have a clean cache each time I save I do "ES3.DeleteFile("Cache");" every time I save. Is this operation costly performance wise? If yes, can I overwrite the cache differently?
Best,
Yes I have followed the guide. The thing is that I save like 600+ gameobjects so a hiccup seem inevitable when you iterate over that long list and do operations on each objects.
Now the act of saving only freeze the frame for like 0.1 or 0.2 seconds so it's not that dramatic but I would like to get rid of that if possible.
Running a thread with async await is tricky because I sometimes save gameobjects or transforms, and I can only do this in the main thread.
Also in order to have a clean cache each time I save I do "ES3.DeleteFile("Cache");" every time I save. Is this operation costly performance wise? If yes, can I overwrite the cache differently?
Best,
Re: Is it possible to save asynchronously?
Hi there,
Due to the quantity of objects it will be inherently slow to right due to the amount of data.
In this case I would recommend splitting your save calls over multiple frames using a coroutine, rather than doing it over a single frame.
Just to clarify, ES3.DeleteFile isn't a costly operation so you shouldn't need to worry about this.
All the best,
Joel
Due to the quantity of objects it will be inherently slow to right due to the amount of data.
In this case I would recommend splitting your save calls over multiple frames using a coroutine, rather than doing it over a single frame.
Just to clarify, ES3.DeleteFile isn't a costly operation so you shouldn't need to worry about this.
All the best,
Joel
-
- Posts: 23
- Joined: Sat Sep 05, 2020 12:53 pm
Re: Is it possible to save asynchronously?
Thanks for the clarifications!
How would splitting calls over multiple frames would look like in code?
If I have 600 objects, does that mean it will take 600 frames to finish the saving process?
How would splitting calls over multiple frames would look like in code?
If I have 600 objects, does that mean it will take 600 frames to finish the saving process?
Re: Is it possible to save asynchronously?
Hi there,
You would do more than one per frame. For example, 10 per frame could look something like this:
All the best,
Joel
You would do more than one per frame. For example, 10 per frame could look something like this:
Code: Select all
ES3.Save("gameObjectCount", myGameObjects.Length);
for(int i=0; i<myGameObjects.Length; i++)
{
ES3.Save("myGameObject"+i, myGameObjects[i]);
// The % is called the modulo operator, and is worth looking up if you've not used it before.
if(i % 10 == 0)
yield return null;
}
Joel