I am having a problem and can’t seem to find a solution. I know how to set a scene to change, I can enter a room, cross it and enter another door/scene. My problem is that when I reenter the first scene, I spawn back at the place where I first entered the room. Is there a way to control where the player will respawn? Is it possible to actually move the player character to other scenes without copying it to all the scenes?
You could use variables written in python and have your character linked to it
You need to store the Object status (position, properties etc.) somewhere. This is usually done with a Python controller.
You can use the SaveLoader to do that or write own code to store and restore.
import GameLogic import copy Pkey = "storageKey" ''' the value of this property is used as key to globalDict. Make sure it is unique within a scene. Make sure the synchrinized object in the other scene gets the same property value. Default is the object name. ''' def store(cont): if noSensorIsPositive(cont): return own = cont.owner key = own.get(Pkey,own.name) transmissionData = TransmissionData(own) GameLogic.globalDict[key] = transmissionData def restore(cont): if noSensorIsPositive(cont): return own = cont.owner key = own.get(Pkey,own.name) transmissionData = GameLogic.globalDict.get(key) if transmissionData is None: return transmissionData.applyTo(own) def noSensorIsPositive(cont): for sensor in cont.sensors: if sensor.positive: return False return True class TransmissionData(object): def __init__(self, gameObject): self.gameObjectName = gameObject.name self.position = copy.copy(gameObject.worldPosition) self.orientation = copy.copy(gameObject.worldOrientation) def applyTo(self, gameObject): gameObject.worldPosition = self.position gameObject.worldOrientation = self.orientation
Python controller in MODULE mode:
before leaving the scene
after entering a scene
Make sure both objects have the same name or the same property “storageKey” with the same value.
Thanks Monster, I’ll read through the link you provided and see what I can do. I have a feeling that this is going to take a few days to figure out, that’s not a problem since I’ve spent almost two years on this game already. I’ll post here when I have more news or more questions.