So I’m having a little issue using while loops inside of a coroutine. I think it could just be my poor understanding of coroutines in general. I have this real simple coroutine I have been calling in order to move my camera around and point it at various objects. The movement works pretty well however I don’t really understand how to get code outside of the while loop inside the coroutine to run? Does this have to do with where I am yielding? Here’s my code
IEnumerator repositionCam () {
while (cameraMovement < 1) {
cameraMovement += camFocusSpeed * Time.deltaTime;
transform.position = Vector3.Lerp(transform.position, transform.position + offset, cameraMovement);
yield return null;
}
Debug.Log("This code never runs");
}
Why is that code down there never executing? How could I hook into something (another method, whatever) once I hit cameraMovement > 1.
I’ve tried placing the return outisde of the while loop but that seems to actually crash unity…