# Some smart saving tricks!

**URL:** <https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733>\
**Category:** Blueprint\
**Tags:** savegame, autosave, unreal-engine, Blueprint\
**Created:** [October 18, 2023, 2:06pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733 "2023-10-18T14:06:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [October 18, 2023, 2:06pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/1 "2023-10-18T14:06:29Z")

</div>

- Save whole data on ESC pressed (if you have an ESC menu)
- Save whole data on Left-Alt pressed (if player is about to ALT-F4)
- ~~Save data on a timer that ticks every 1-2 seconds.~~ (see below)

These are some “smart-saving” methods I could think of. 😃 What do you guys think, what else could be used? Are these methods good/bad? Will they cause optimisation issues?

In my case, I’m working on a small RPG project so I have to consistently save player data (stats/items/experience/currency/location/etc.).

Feel free to drop down any tips/tricks you use/have used for your games.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 18, 2023, 2:14pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/2 "2023-10-18T14:14:51Z")

</div>

Are these supposed to be dev tips? Or under the hood implementation methods related to saving data?

> Save data on a timer that ticks every 1-2 seconds.

I wouldn’t go this way. Sounds like a disaster waiting to happen. But intercepting keys is generally a good idea.

---

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [October 18, 2023, 2:40pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/3 "2023-10-18T14:40:07Z")

</div>

They are some ideas that came to my mind about making a simple auto-save system 🙂

> [@Everynone](#):
>
> I wouldn’t go this way. Sounds like a disaster waiting to happen. But intercepting keys is generally a good idea.

I was wondering if this case was a bad idea, could you elaborate what might happen if this was to be implemented? Currently I just have the first two options in my game.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 18, 2023, 2:44pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/4 "2023-10-18T14:44:58Z")

</div>

- let’s say you’re saving every 1s but saving takes longer than 1 second, now we’re in trouble
- the end user has a 🥔 PC with a slow HDD, and now they get a consistent frame hitch every 2s
- player goes idle for 1h, during which we’ve unnecessarily saved nearly 2000 times; every 2s

* * *

> a small RPG project so I have to consistently save player data

Perhaps saving could be done in an event based manner - when data changes?

---

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [October 18, 2023, 2:50pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/5 "2023-10-18T14:50:40Z")

</div>

Great points, lol! I especially love the last one, saving 2000 times, yikes. 🤣

Well these points are more than enough to disqualify that option then.

> [@Everynone](#):
>
> Perhaps saving could be done in an event based manner - when data changes?

Looks like this is the direction I’ll be going in. Save after data changes - experience gain/quest completion/item looted and so on.

Great tip(s) as usual @Everynone! Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 18, 2023, 3:00pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/6 "2023-10-18T15:00:37Z")

</div>

> [@isikdev](#):
>
> Well these points are more than enough to disqualify that option then.

I mean, it’s not a bad idea per se. It’s just that saving non-stop may not be necessary. You could consider a smart_ish_ system:

- autosave if no save was done in the last minute
- autosave only if data actually changed

When the player: _moves, fiddles with inventory, clicks through dialogue, flips through options_ - set a `dirty flag` in the save game system stating that data needs saving. This could start a timer; if no other save happens in the next 60s, `autosave` now. Clear `dirty flags`. Any type of saving that you have already set up clears those flags as well.

- pop an autosaving icon to warn the player?
- let them disable autosaving / control how often it happens?

---

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [October 18, 2023, 3:05pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/7 "2023-10-18T15:05:18Z")

</div>

Lovely ideas. Definitely have to make it “smart” if its going to constantly save.

> [@Everynone](#):
>
> When the player: _moves, fiddles with inventory, clicks through dialogue, flips through options_ - set a `dirty flag` in the save game system stating that data needs saving. This could start a timer; if no other save happens in the next 60s, `autosave` now. Clear `dirty flags`. Any type of saving that you have already set up clears those flags as well.

If the 3rd option was to be implemented, this would be the _ **best** _ way to go about it. I think I will do something similar to this! Hats off to you.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 18, 2023, 3:49pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/8 "2023-10-18T15:49:24Z")

</div>

Not sure if _the best_ but I had something along the lines of:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/4/224665eaa6ce0c32d6869c75b8da21fb6534768f.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/c/43ca22a6868ca9d8f79a790b61f481e5396191e1.png)

In the Game Instance.

* * *

This is all pseudoscript, ofc, and would need to be tested for logic loopholes. But essentially:

- ask the system to autosave when something important enough happens
- execute the autosave after some time providing the player is not busy or hasn’t already saved in some other way
- if autosave could not complete, try again

---

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [October 18, 2023, 3:57pm UTC](https://forums.unrealengine.com/t/some-smart-saving-tricks/1336733/9 "2023-10-18T15:57:26Z")

</div>

Wow, thanks for dropping an example as well. Perfecto! 🤌
