- Home /
Lerping orthographic camera size jitters
Hi When I try to Lerp the orthographic camera size it makes a nasty jitter at the end instead of a smooth Lerp. I have no idea why, so help would be much appreciated:)
Here is my code:
void Update()
{
StartCoroutine(Zoom(5,2,0.5f));
}
IEnumerator Zoom(float oldSize, float newSize, float time)
{
float elapsed = 0;
while (elapsed <= time)
{
float speed = 0.5f;
elapsed += Time.deltaTime * speed;
float t = elapsed / time;
Camera.main.orthographicSize = Mathf.Lerp(oldSize, newSize, t);
yield return null;
}
}
Answer by Dangerface · Nov 21, 2020 at 09:16 PM
So I kind of found the problem, just leaving this here for future reference.
It does not like to get the Lerp in the Update, Because I'm guessing it gets called a lot - hence the jitter. In my game I only need it to zoom in the beginning of a level, so the solution was just to put coroutine in Start. If you need it to happen mid game it should be set of by a one time trigger I guess :)
Your answer
Follow this Question
Related Questions
How to zoom in smoothly with orthographic camera? 1 Answer
Physics + first person camera = jitter? 4 Answers
Camera jitter when using Lerp/Slerp 1 Answer
Camera Lerp Jitter 0 Answers
Why is the camera aspect ratio broken for the game tab? 0 Answers