Set the last location of an object in scene 1 to the beginning of scene 2

Hi guys,

I’m trying to learn BGE and python scripting.

I’ve downloaded the blendenzo .blend for training, and tried some things.

I’ve read a lot of tutorials, and a lot of posts on different forums, but i don’t succeed in improvement.

i would like to get the last location of the player object in a scene, and have this player object beginning another scene at the same location, wherever it was in the first scene, as if the action restarts exactly where it stopped.

Here is the .blend i played with.

Control_LBVERnew.blend (484 KB)

Could someone explain me how to do this ?

And by the way, it seems that the “setPosition” attribute in KX_GameObject does no longer exist in BGE 2.66 API.

Best regards

I recommend to look for save/load in the resource forum.

Thank you Monster.

I have also your very interesting “guide to python coding” in the folder where I put all the resources I find about bge.

Before I wrote my request above, I have read some posts about save/load, and also a blurry discuss about a script for managing objects of a non-current scene in the current scene. It seemed to me that all of these would help me, but I don’t find the way to make all it work properly.

And, about save/load, would it be convenient for a standalone game ? Wouldn’t it be better to create a variable which would be callable in the second scene ?

Sorry for those silly questions, but although I really want to understand, and work hard for it, it appears that I might have a Gnocchi brain.

Anyway, I go straight in the resource forum, and look again for what you told me.

I’m afraid I’ll be back soon here…:smiley:

The basics is this:

save/load should be split up into 2 areas:

  • store/restore to non-persistent
  • save/load persistent

the most implementation of save/load do the mistake to mix this together. This prevents to use them for more than to write data to file.

A good design allows to use this for save to file, transfer over network, transfer data to over scene/game.

What you need is to store data in a non-persistent are (like a dict) and restore it in a different scene. There is nothing to prevent you to restore data at a different object.

E.g. you stored an objects position “player” from Scene “level A” and restore it at object “otherPlayer” in Scene “level B”.

You can have a look at my SaveLoader (you can find it in my libraries link). It might be a bit overhead, but it does exactly that. The demo shows how to work with different scenes.

Yes, since your first post on this topic, i’ve already downloaded your Saveloader 2.7 demo. I just didn’t get the time to have a deeper look in it this morning.

E.g. you stored an objects position “player” from Scene “level A” and restore it at object “otherPlayer” in Scene “level B”.

In fact, i would like to restore the position at the same player in scene B.

Let me dive in your Saveloader, I’ll be back after, probably tomorrow.

Thank you again, a lot, for the time you spend to share your aknowledgement !! :cool: