Saved Game loading off by 1

I have a saved game system that is similar to the one in Crash Bandicoot. However, instead of a warp room, each level is presented sequentially in a persistent level, giving the impression of one large continuous level. At the end of each sublevel, the player is given the opportunity to save. When the player loads a game, they are presented with a list of all of the sublevels they’ve reach so they can replay levels if they want.

The system works correctly except that when a game is loaded, the player is set back by one level. So if the player chose to load in level 5, the player is placed at the beginning of level 4. If loading in level 2, the player is placed at the beginning of the game. I would have expected an error here since as far as I know, no data is saved at the beginning of level 1, but I don’t get any errors.

I’ve tried offsetting the integer that picks the level, but it doesn’t fix the issue.



I don’t know that the problem is in either of these blueprints, but here is a part of the Game Instance.

I did not look in your code, but it may be dreaded indexing of arrays (or lists in case of blueprints).

Make sure your code counts in range of 0 … length_of_array-1.
Not 1 … length. It is really messy thing in I think all coding languages.
There is no escape from scratching head if for loop of 1 … max_length or 0 … max_length-1 is correct one.

oh ond for debug print those index values, or make widget that shows them.

1 Like

Well I tried adding 1 to the loaded number, and now it works for some reason. I have absolutely no idea why it works now as opposed to when I tried it earlier. So sounds like you were probably right.

Investigate why it works and why it did not. You have fresh memory of that code and great example of that quite common mistake. Learn from it now or you will repeat it again. Now it is easier.

1 Like