So, I have this cinematic sequence where the camera changes state from following the character to entering a camera “path”. It’s mostly used for reveal sequences and such.
It looks a bit like this:
IEnumerator MoveCamera(Cinematic cinematic)
{
float timePassed = 0;
float hermiteLerpFactor;
mainCamera.camstate = MainCamera.CamState.Cinematic;
while(cinematic.duration - timePassed >= 0)
{
// Ease-In / Ease-Out
hermiteLerpFactor = Mathfx.Hermite(0, 1, timePassed/cinematic.duration);
mainCamera.gameObject.transform.position = Vector3.Lerp(cinematic.start.position,
cinematic.end.position,
hermiteLerpFactor);
timePassed += Time.deltaTime;
yield return null;
}
yield return new WaitForSeconds(cinematic.totalDuration - cinematic.duration);
mainCamera.camstate = MainCamera.CamState.Follow;
}
So, what I do to skip the cinematic is to set duration and totalduration to 0, and this seems to work okay. The coroutine quickly finish.
However, I mainly wonder how I could safely pause this cinematic sequence (or any other coroutine for that matter).
Also, I wonder if it’s ok to use a coroutine like that…?
Thanks for any help and guidance.
Kjetil