Exemple #1
0
    public void SpawnPlayer()
    {
        var savedName = default(string);

        if (dataManager)
        {
            savedName = dataManager.GetCurLevelName();
            if (overrideCheckPoint)
            {
                curCheckPoint = checkPoint;
            }
            else if (savedName == sceneTransData.GetCurLevelName())
            {
                curCheckPoint = dataManager.GetCurCheckPoint();
                Debug.Log("Saved level name matches current level...spawning player at checkpoint " + curCheckPoint);
            }
            else
            {
                Debug.Log("Saved level name does not match current level name...Resetting checkpoint to 0");
                curCheckPoint = 0;
            }
        }

        //store spawn in transform var for respawn use
        GameManager.instance.SpawnedPlayer = Instantiate(playerSpawn, checkPoints[curCheckPoint].worldPos,
                                                         Quaternion.identity).GetComponent <Player>();
    }