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
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
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:
return
owner = controller.owner
objectStorage = {}
objectStorage["position"] = list(owner.worldPosition)
storage[owner.name] = objectStorage
def restorePosition(controller):
if not controller.sensors[0].positive:
return
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.