The function of the first lerp is to bring the GUITexture onto the screen, and this works beautifully. The second lerp is supposed to bring it back off screen, and while it does that, it does not seem to lerp. It immediately goes off screen when waitTime >= 8.0f and I don't know why. void Update () { if (gotDeliverance == true && doneDeliverance == 0){ deliverance.pixelInset = newInset; waitTime += Time.deltaTime; if (waitTime < 8.0f){ newInset = new Rect((Screen.width / 2) - deliverance.pixelInset.width, Mathf.Lerp ((Screen.height / -2) - deliverance.pixelInset.height, Screen.height / -2, Time.time / 6), deliverance.pixelInset.width, deliverance.pixelInset.height); } else if (waitTime >= 8.0f && waitTime < 16.0f){ newInset = new Rect((Screen.width / 2) - deliverance.pixelInset.width, Mathf.Lerp (Screen.height / -2, (Screen.height / -2) - deliverance.pixelInset.height, Time.time / 6), deliverance.pixelInset.width, deliverance.pixelInset.height); } else{ waitTime = 0; PlayerPrefs.SetInt ("deliverance", 1); doneDeliverance = 1; } } }
Please use code tags: http://forum.unity3d.com/threads/using-code-tags-properly.143875/ Using Time.time in combination with Mathf.Lerp is in general not clever. It is really unfortunate that Unity is using that combination in the documentation. The last value in lerp is supposed to be between 0 and 1. If it is not, it will automatically be clamped. What you do is: Code (csharp): Mathf.Lerp (from, to, Time.time / 6); As Time.time returns the time passed since the start, it will be pretty useless after 6 seconds, because Time.time / 6 will become greater than 1 and as such Mathf.Lerp will just treat it as if it was 1.