- Home /
How can I get my camera to momentarily pause between different positions when using lerp?
I have an array of positions that I want my camera to move/lerp between. There are two buttons (button A and button B) that trigger the camera to move position. If the user presses button A, the camera will lerp to the previous position in the array. If the user presses button B, the camera will lerp to the next position in the array. However, before moving to a new position, I want the camera to lerp to an intermediate position, pause there for a couple of seconds, and then move. Here is the pseudocode for what I have at the moment:
void Update()
{
if (buttonPress == a) {
positionToMoveTo = positions[currentPosition--];
}
if (buttonpress == b) {
positionToMoveTo = positions[currentPosition++];
}
}
void LateUpdate()
{
camera.lerp(intermediatePosition);
StartCoroutine(pause());
}
IEnumerator pause()
{
yield return new WaitForSeconds(3f);
camera.lerp(positionToMoveTo);
}
This doesn't work though because I get strange jittering when switching camera positions and my intermediate position doesn't always occur. I think my problem has something to do with execution order but I can't figure it out. Any help would be great :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612180227im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Update/Late Update jitter problem(non FixedUpdate related) 1 Answer
Wait before zooming camera at the start of level 1 Answer
restrict Lerp to only one axis? 1 Answer
Camera not slowly moving to object 0 Answers
How to restrict rotation properly 2 Answers