// This kicks off the coroutine which changes the perspective public void startSwitch(PlayerMount targettedMount) { stopLoad(); OnStartSwitch(); audio.Play(); lastCoroutine = StartCoroutine(switchPerspective(targettedMount)); }
// Here's the coroutine which moves the player to the new perspective new protected IEnumerator switchPerspective(PlayerMount targettedMount) { Transform target = targettedMount.transform; float dist = (target.position - transform.position).magnitude; while (dist > 0.4) { transform.position = Vector3.Lerp(transform.position, target.position, transferSpeed); targettedMount.transform.rotation = Quaternion.Lerp(targettedMount.transform.rotation, this.transform.rotation, transferSpeed); //transform.rotation = target.rotation;// Quaternion.Lerp(transform.rotation, target.rotation, transferSpeed); dist = (target.position - transform.position).magnitude; //targettedMount.avatarMaterial.SetColor("Albedo",) yield return(null); } //yield return null; targettedMount.isMounted = true; //targettedMount.transform.LookAt(this.transform.position + this.transform.forward); for (int i = 0; i < targettedMount.mountableAvatarParts.Length; i++) { targettedMount.mountableAvatarParts[i].SetActive(false); } //yield return null; targettedMount.transform.rotation = this.transform.rotation; targettedMount.transform.SetParent(this.transform); //base.switchPerspective(); }
// Starts the coroutine that starts a timer which counts down until we transition to the new mount position public void startLoad() { PlayerMount targettedMount = getTargettedMount(); if (targettedMount) { if (!targettedMount.isMounted) { lastCoroutine = StartCoroutine(Load(targettedMount)); } } }
// This is the coroutine which Loads up the reticle. Once the while loop is finished we switch our perspective to the new mount protected IEnumerator Load(PlayerMount targettedMount) { while (reticle.fillAmount < 1.0) { reticle.fillAmount += loadSpeed; yield return(null); } for (int i = 0; i < mounts.Length; i++) { mounts[i].isMounted = false; } startSwitch(targettedMount); }
// Here's the coroutine which moves the player to the new perspective new private IEnumerator switchPerspective(PlayerMount targettedMount) { Transform target = targettedMount.transform; //while (blinkAmount < 1.0) //{ // blinkAmount += transferSpeed/2; // yield return null; //} targettedMount.isMounted = true; transform.position = target.position; //for (int i = 0; i < targettedMount.mountableAvatarParts.Length; i++) //{ // targettedMount.mountableAvatarParts[i].SetActive(false); //} ////yield return null; //while (blinkAmount > 0.0) //{ // blinkAmount -= transferSpeed / 2; // yield return null; //} //yield return null; //targettedMount.transform.rotation = this.transform.rotation; //targettedMount.transform.SetParent(this.transform); if (OnMount != null) { OnMount(); } yield return(null); }
// Here's the coroutine which moves the player to the new perspective virtual protected IEnumerator switchPerspective(PlayerMount targettedMount) { OnMount(); yield return(null); }