I'm making quite a big game with levels but I just have to figure out how to save and load the characters position. I've already managed to make it work with properties.

I've tried some things but they dont seem to work. My version is 2.76

  • 2
    $\begingroup$ Please elaborate a bit on what you have tried and why it didn't work. $\endgroup$ – Duarte Farrajota Ramos Nov 10 '16 at 19:32
  • $\begingroup$ youtube.com/watch?v=XcWsCEAqTNE I basically tried this, but it's not working. $\endgroup$ – Luis fdez96 Nov 10 '16 at 21:09
  • 2
    $\begingroup$ @Luisfdez96 Very few people are going to want to watch a tutorial (however short) to answer your question. Please include details of what you have tried within the question itself, with screenshots if necessary. $\endgroup$ – Ray Mairlot Nov 11 '16 at 15:21

Basically you can store the data to be saved in bge.logic.globalDict via Python.

The save actuator writes this data to a file.

The load actuator loads it back from file when you need it.

Then you modify the scene according to the data in bge.logic.globalDict via Python.

This means:

  • saving and loading can be easily performed by logic bricks

  • storing and restoring as very custom operations as you are the only one that knows what should be stored how. You need Python to do that.

As this can quickly become a quite complex task I suggest you look for other tutorials on save/load. Questions regarding the tutorial should be ask to the tutorial author.

Just in case a small hint is enough:

import bge

storage = bge.logic.globalDict

def storePosition(controller):
    if not controller.sensors[0].positive:

    owner = controller.owner

    objectStorage = {}
    objectStorage["position"] = list(owner.worldPosition)

    storage[owner.name] = objectStorage

def restorePosition(controller):
    if not controller.sensors[0].positive:

    owner = controller.owner

    objectStorage = storage.get(owner.name)
    if objectStorage:
        owner.worldPosition = objectStorage.get("position", owner.worldPosition)

If you do not enough python/bge-api to understand this code, I strongly suggest to learn it first.


Your Answer

