Query on Save/Load game, specifically regarding objects already collected

I am adding a Save/Load game feature to my game, that will save the players score/time/health/position at the time they pass through a checkpoint.

My query or concern is about any previous items that player may have already collected.

If these weren’t registered at the point of the save/load state, does this effectively mean everything else in the world will remain, even if at the point of saving those items had already been collected?

The items I am referring to are:

  • Actors that are destroyed once passed through eg. adding to the score.
  • Health Pickups.
  • A couple of game items needed for the player progression.

Before I got too far ahead on creating this blueprint I wanted to query this.

Is there a feature or record within the blueprint that can read the current level state and recall if any actors have been destroyed/collected?

I want to make sure that all items/actors previous collected or destroyed, are also remembered at the point of save/load.

Thank you for any help!

Wouldn’t that be nice :smiley:

Nope, sorry, you have to code the whole thing.

It’s up to you how you do that. Do you want things to save as they change, or only save at a checkpoint etc, but

After loading the level - it will be as you made it in the editor. Everything you did during the game - is not initially taken into account.

Your save system should keep track of what world items are in your inventory and remove them from the level after loading if they are collected to prevent them from being cloned.

No, all that is there initially in blueprint is a “Save Game” flag for variables (which initially has no effect on anything).
With it you mark which variables need to be serialized, then you add this data to the save file.
This is described here in maximum detail.

I have probably 18 pickups or so, along with 15 score actors that are destroyed on collision.

Ideally, I’d like the system to remember which actors/objects have been destroyed, so that when the player reaches a checkpoint, that information is remembered, preventing duplicate items from reappearing on load.

1 Like

If you make a generic pickup parent, that knows how to save itself ( and destroy itself on next play if need be ), then your other pickups can derive from that class.

It sounds like a lot of work, but to be honest, using the save flag and serialization ( as outlined by @PREDALIEN ) sounds worse :joy:

It’s really up to you which way you go…

Isn’t this the most universal solution that Epic themselves have built the foundation for?

The “Save Game” flag does just that.

1 Like

It is yes, but it’s not always the case that something is good, just because Epic made it :melting_face:

If you’re only working in BP, and only need to save a few things, its a bit overkill.

Unfortunately you are right, but the “Save Game” flag was definitely a good solution (but not fully implemented).

“My” solution is revealed after you want to save the item after you dropped it in the level in a new place.
Thanks to serialization, you will load ALL (the ones you need) its parameters by calling one universal function, without thinking about the fact that the classes of objects are different.

But this is only PART of the save system. The part that monitors whether the level object has been collected is not directly related to serialization.

1 Like

Agreed, it’s nearly a nice system :slight_smile:

1 Like

Out of curiosity what parameter do you use to identify the specific instances of savable / destroyed objects?

Do you have an internal index on the actors or use their GUID? Saving out direct full references can probably get heavy memory wise.

Actor Soft Object Reference (Object Path).

In the save file, you need to store the path of the object that we have collected. For actors that are initially on the level, this is a reliable identifier that does not change when the level is reloaded.

After loading the level, you need to check which of the collected items are on the level (ActorSoftObjectReference->Resolve->IsValid) and remove them from the level.

With dynamic objects, things are more complicated.
It is necessary to create your own system of reliable identifiers that will be assigned to unique spawning objects in a particular case.
The standard Unreal ID system cannot provide this.

References for the base class (actor) are cheap.

1 Like

My initial concern seems to be put at rest.

Upon implementing my save/load feature, the system automatically remembered which actors were destroyed at the point the game was saved, such as a few actors that affect the score mechanic!

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