Player spawns facing the wrong direction.

I am making an fps and when I walk up and down stairs, it changes levels (scenes). I made it so it keeps all of the player and menu info saved so that when it loads into the next scene it is the same. However, going from room 1 to room 2, the player spawns facing the door to the stairs he just came from, yet if I go back to room 1 from room 2, he faces the rest of the room and not the door he came from, which is what I want for the first situation. Here’s the code for transition:

public class LevelTransition : MonoBehaviour
{
public string LevelName = string.Empty;
public string SpawnName = string.Empty;

public GameObject Player;
public GameObject GameUI;
public GameObject MenuAnchor;
public GameObject Minimap;

public void OnTriggerEnter(Collider collision)
{
    if (collision.tag == "Player")
    {
        Transition();
    }
}

void Awake()
{
    Player = GameObject.Find("Player");
    GameUI = GameObject.Find("Game UI");
    MenuAnchor = GameObject.Find("Menu Anchor");
    Minimap = GameObject.Find("Minimap");
}

void OnClick()
{
    Player.SetActive(true);
    Minimap.SetActive(true);
    Minimap.GetComponent<Camera>().depth = 5f;
    NGUITools.SetActive(GameUI, true);
    NGUITools.SetActive(MenuAnchor, true);

    Transition();
}

void Transition()
{
    DontDestroyOnLoad(this.gameObject);
    Application.LoadLevel(LevelName);
    LoadedResources.ReloadAll();

    Screen.lockCursor = true;
}

}

this is probably so simple to do but I’m blanking please and thanks for the help.

On the scene, try rotating your Player Game Object where it begins.

Okay for one thing I’m not sure you need to call DontDestroyOnLoad(this.gameObject); every time you do a transition, you should be able to call that once on a script on your player and it should be good to go the rest of the game.

So what I would do here is add a var to your player on a script somewhere that saves the ‘lastLevel’ you were on. You could save that any way you want, let’s say it’s just an int and you load up level 1. Set lastLevel to 1.

Then when you load level two, you could add something in a Start() method that looks for your player GameObject and then gets that lastLevel variable. Then you could set up a switch() statement to set the position and rotation of your player, then set the lastLevel to the new level you just loaded.

So something like creating a LevelManager script on your player and then check/set the variable:

void Start() {

Player = GameObject.Find("Player");
int lastLevel = Player.GetComponent<LevelManager>().lastLevel;

switch (lastLevel) {
default:
break;
case 1:
// set your player position and rotation here
break;
case 2:
break;
//etc etc 
}

// then set the lastLevel int to your new level here
}

Your Player is a prefab right? You should be able to test directly in your scene by loading it up in your editor and then dropping your player in. You could then set the lastLevel manually that way you could test the different directions / scenarios.