Ejemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name.Contains("Skater"))
     {
         Respawn r = PlayerController.Instance.respawn;
         // Break the pointer reference
         Vector3 playerOffset = r.getSpawn[0].position - r.getSpawn[1].position - new Vector3(0.0f, 0.08f, 0.0f);
         this._pinPos  = new Vector3(r.pin.position.x, r.pin.position.y, r.pin.position.z);
         this._pinQuat = new Quaternion(r.pin.rotation.x, r.pin.rotation.y, r.pin.rotation.z, r.pin.rotation.w);
         r.SetSpawnPos(this._destination.position - playerOffset, this._destination.rotation);
         r.DoRespawn();
         r.SetSpawnPos(this._pinPos - playerOffset, this._pinQuat);
     }
 }
        private static IEnumerator <UnityEngine.Coroutine> OnMapChanged(string name)
        {
            LevelManager manager   = LevelManager.Instance;
            string       levelName = CleanLevelName(manager.currentLevel.FullName); // Just in case this acts as a pointer.

            if (Path.GetFileName(name) == levelName)
            {
                Respawn   r           = PlayerController.Instance.respawn;
                Transform playerXform = PlayerController.Instance.boardController.boardTransform;
                // Create a copy since transform is a pointer
                playerPos = new Vector3(playerXform.position.x, playerXform.position.y, playerXform.position.z);
                playerRot = new Quaternion(playerXform.rotation.x, playerXform.rotation.y, playerXform.rotation.z, playerXform.rotation.w);
                spawnPos  = new Vector3(r.pin.position.x, r.pin.position.y, r.pin.position.z);
                spawnRot  = new Quaternion(r.pin.rotation.x, r.pin.rotation.y, r.pin.rotation.z, r.pin.rotation.w);

                yield return(manager.StartCoroutine(manager.PlayLevelRoutine(manager.currentLevel)));

                r.SetSpawnPos(playerPos, playerRot);
                r.ForceRespawn();
                r.SetSpawnPos(spawnPos, spawnRot);
            }
            yield return(null);
        }