1
$\begingroup$

How can the character (red star) go thru a door from Scene1 to Scene2? Scene 1 is the current one and Scene2 is to be loaded after the character go thru the door. Scene1 is the exterior and Scene2 is a building.

I've created a blend file as per coments but is not working. Description

$\endgroup$
  • $\begingroup$ You could add a cube that has static physics, make it invisible, put it in the door, and put a logic brick Collision on the cube. Add a property to the player called something like change_scene set the collision type to property and enter that name. Then hook that up to an And and then to a Set Scene $\endgroup$ – BlendingJake Nov 21 '14 at 22:17
  • $\begingroup$ To make it simple, I just want to change the scenes in game from outside to inside and vice versa, the ideea is not to load all the scene from one go. $\endgroup$ – godolomn Nov 21 '14 at 22:40
  • $\begingroup$ This isn't loading all the scenes, all this would do is change the scene when you passed through the doorway. $\endgroup$ – BlendingJake Nov 22 '14 at 2:48
  • $\begingroup$ Thanks BlendingJake. And can I keep the character in Scene2? $\endgroup$ – godolomn Nov 24 '14 at 21:30
2
$\begingroup$

You wont be able to actually "transfer" the player object in-game. But you can create an instance of the player in each scene beforehand.

  1. Move the player to (0, 0, 0) on a non-visible layer
  2. Add it to a new group. I named mine "Player"
  3. Do Shift+A -> Group Instance -> Player in each scene that needs to contain the player.

Creating a group object

This method will not copy properties that have changed since the scene started. You'll likely need a Python script for that.

EDIT - Quick example of transferring specific properties between scenes

1. Run this on your player right before changing scenes

import bge

def saveProps(cont):
    own = cont.owner

    props = {}
    props['name_of_property'] = own['name_of_property']
    props['another_property'] = own['another_property']
    # ... etc

    bge.logic.player_props = props

if __name__ == '__main__':
    cont = bge.logic.getCurrentController()
    saveProps(cont)

2. And run this when a scene first loads, basically the first script in reverse.

import bge

def getProps(cont):
    own = cont.owner

    try:
        props = bge.logic.player_props
    except:
        # Props dict not defined.  This was likely the first scene.
        return

    own['name_of_property'] = props['name_of_property']
    own['another_property'] = props['another_property']

if __name__ == '__main__':
    cont = bge.logic.getCurrentController()
    getProps(cont)
$\endgroup$
  • $\begingroup$ Thank you! Is there any tutorial for properties transfer? $\endgroup$ – godolomn Dec 1 '14 at 20:37
  • $\begingroup$ Added an example of property transfer to the answer $\endgroup$ – pqftgs Dec 20 '14 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.