IEnumerator StartEngine() { foreach (FacingWaypoint wp in waypoints) { Debug.Log("Entering the first waypoint"); switch (wp.myType) { case FacingTypes.FORCED_LOCATION: Debug.Log("Getting into forced location!"); cameraMovementScript.enabled = false; FacingWaypointForcedLocation forcedLocationWaypoint = (FacingWaypointForcedLocation)wp; StartCoroutine(ForcedLookLocation(forcedLocationWaypoint.lookTarget, forcedLocationWaypoint.timeToTarget)); yield return(new WaitForSeconds(forcedLocationWaypoint.timeToTarget)); Debug.Log("Done looking, time to stare!"); yield return(new WaitForSeconds(forcedLocationWaypoint.stareTime)); cameraMovementScript.enabled = true; Debug.Log("Ending the forced location!"); break; case FacingTypes.FREE_MOVEMENT: FacingWaypointFreeMovement freeMovementWaypoint = (FacingWaypointFreeMovement)wp; yield return(new WaitForSeconds(freeMovementWaypoint.freeTime)); break; default: Debug.Log("Inappropriate moving type!"); break; } } }
//Coroutine to run through each waypoint IEnumerator StartEngine() { foreach (FacingWaypoint wp in waypoints) { Debug.Log("Entering the first waypoint"); switch (wp.myType) { case FacingTypes.FORCED_LOCATION: Debug.Log("Getting into forced location!"); //disable free camera movement cameraMovementScript.enabled = false; //save waypoint type FacingWaypointForcedLocation forcedLocationWaypoint = (FacingWaypointForcedLocation)wp; //call another coroutine that handles moving the locked camera to a fixed point StartCoroutine(ForcedLookLocation(forcedLocationWaypoint.lookTarget, forcedLocationWaypoint.timeToTarget)); //wait the amount of time for the camera to move yield return(new WaitForSeconds(forcedLocationWaypoint.timeToTarget)); Debug.Log("Done looking, time to stare!"); //hold camera angle for a variable amount of time yield return(new WaitForSeconds(forcedLocationWaypoint.stareTime)); //enable free camera movement again cameraMovementScript.enabled = true; Debug.Log("Ending the forced location!"); break; case FacingTypes.FREE_MOVEMENT: //save waypoint type FacingWaypointFreeMovement freeMovementWaypoint = (FacingWaypointFreeMovement)wp; //hold on free movement type of control for a variable amount of time yield return(new WaitForSeconds(freeMovementWaypoint.freeTime)); break; default: Debug.Log("Inappropriate moving type!"); break; } } }