Saving and loading game in Armory


#1

Anyone know hot to save/load game in armory
I know you can save data into file like json (doesnt care about cheating now) and then load those data back, this can be easy.
But what i want is to save player loc and then load it again. My idea is to get player loc and then save it as data in json file then load it and then transform the player to save loaction. But there might be other way and not tranform player.
Anyone know how and anyone that have tried that, please feel free to answer me.


#2

I don’t understand the problem.
Save player X,Y,Z location to Json, when you want to load you read Json X,Y,Z and set player location with those values.
You only need to use Json and file save Api.


#3

yeah, but transforming/ setting location of tons of thing might not be good idea


#4

Or use a checkpoint system to make it simple for you, like Halo games :wink:


#5

we don’t want to use checkpoint tho.


#6

That may not be a horrible idea. If you load the json into memory when the game starts, and you load each object’s location from the json in the object’s init function, it might not be much of a performance problem. Armory is already setting all of the objects locations when it loads the scene, so it can’t take any longer to set those object locations than it would to load the scene. It is worth a shot.

I’ve recently discovered that it isn’t a good idea to try and fix performance issues that you don’t know are actually performance issues. Obviously you want to be performance conscious, but don’t over-engineer solutions to try and avoid issues that might not be issues. ( I was writing a script and added an on-disk cache to avoid heavy memory usage before finding that the amount of memory it required was hardly anything and that trying to make an on disk cache just made everything slower. :slight_smile: )


#7

I was in a similar situation:
I had a lot of things that may be moved by the player, doors that should stay open, objects that have been collected and so on.

My solution was to have a json file with the original map and a second json file (the save file) with the changes.

Loading:
When the game loads up the Level it reads the original map and alters it according to the save file:
Example Map:

  • Door 1 - closed
  • Door 2 - closed
  • Door 3 - closed

Example save:

  • Door 2 - opened

Result of loaded map:

  • Door 1 - closed
  • Door 2 - opened
  • Door 3 - closed

Saving
The games looks at the current states of all objects. If they a state is different from the original map it saves the change to the save file.

The Advantage was that you have the same original map for all save files. Even if different users were playing on the same machine. And the save files are not as big as saving the whole map for every state for every user.

But if you just want to save the Position of the Player its a bit to complex.