private IEnumerator MoveToNextPlantform() { Plantform p = PlantformMgr.plantforms[curPlantform]; foreach (var arch in p.archMgrs) { arch.SetFadeOut(); } yield return(MoveToTarget("PlantformPos")); curPlantform++; if (curPlantform == PlantformMgr.plantforms.Count) { TTUIPage.ShowPage <PassedUIPage>(); yield break; } yield return(MoveToTarget("PlayerPos")); ply.isMoveing = false; }
IEnumerator MoveToTarget(string target) { Plantform p = PlantformMgr.plantforms[curPlantform]; Transform tar = p.transform.Find(target); Vector3 startPos = ply.transform.position; Quaternion startRot = ply.transform.rotation; Vector3 endPos = tar.position; Quaternion endRot = tar.rotation; float tMove = 0; float tRot = 0; while (tMove < 0.95f) { tMove += 1 / moveTime * Time.deltaTime; tRot += 1 / rotTime * Time.deltaTime; ply.transform.position = Vector3.Lerp(startPos, endPos, tMove); ply.transform.rotation = Quaternion.Lerp(startRot, endRot, tRot); yield return(null); } yield break; }