Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Rooms transition

Discussion in 'Scripting' started by AnduinGaiden, Feb 22, 2015.

  1. AnduinGaiden

    AnduinGaiden

    Joined:
    Feb 13, 2015
    Posts:
    9
    Hello guys, I'm developing a platform game that is composed by a sequence of rooms (each room is a different scene) where the character will be going back and forth. Each room has an entrance point and an exit point. It was easy to set up the game to make the character goes to the next room once he arrived at the exit point from the room where he is. The problem is that the character also will be able to go back to the room he just left and he needs to be placed at the exit point of the previous room.

    I was thinking about put a game object on the exit point of each room but I do not know if I'll be able to access this gameObject being in another scene.

    Any ideas?

    Thanks in advance!
     
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    This is probably where you want to create a game manager. You just create a scene called init, and an empty game object with a script attached, and in the awake of the script you set the game object to DontDestroyOnLoad. Then in the start of the script, you load the next scene using a public variable so you can easily change it in the editor to whatever scene you are working on or later to the menu. I think there is a tutorial in the learn section. The game manager can keep track of the last scene before this one was loaded or whatever else you want to keep track of. The only difference is when you test your game, you always have to start from the init scene.
     
  3. AnduinGaiden

    AnduinGaiden

    Joined:
    Feb 13, 2015
    Posts:
    9
    Nice, I'll try to check the tutorials in order to try to find the one you mentioned! Thanks!