Exemple #1
0
        private void UpdatePlayer(ScenePortal otherScenePortal)
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");

            player.GetComponent <NavMeshAgent>().Warp(otherScenePortal.spawnPoint.position);
            player.transform.rotation = otherScenePortal.spawnPoint.rotation;
        }
Exemple #2
0
        private IEnumerator Transition()
        {
            if (sceneToLoad == " ")
            {
                Debug.LogError("scene to load not set");
                yield break;
            }
            DontDestroyOnLoad(gameObject);

            Fader            fader            = FindObjectOfType <Fader>();
            SavingWrapper    wrapper          = FindObjectOfType <SavingWrapper>();
            PlayerController playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            wrapper.Save();
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            PlayerController newPlayerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

            newPlayerController.enabled = false;
            wrapper.Load();

            ScenePortal otherScenePortal = GetOtherPortal();

            UpdatePlayer(otherScenePortal);
            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);
            newPlayerController.enabled = true;

            Destroy(gameObject);
        }