How to end a cinematic camera cycle

Hi, I’m new in Unity and I’m learning on my own how to use it

For starters I’m trying to combine different scripts from tutorials into a new project so I can see better what how code works in different contexts

Right now I’m trying to start a 1° person test game with a cynematic sequence. I’ve worked out how to switch to the player camera (I’ve resorted to just deactivate the cinematic cameras) but the cycle keeps going. I know I should use break but I don’t know how to change the code now

public static bool gameStarted = false;

[SerializeField]
private List<GameObject> cinematicCameras;
[SerializeField]
private Image screenFader;

private int activeCamera = 0;
private int nextCamera;

private float timer;

[SerializeField]
private float timerDelay = 8f;
[SerializeField]
private float fadeSpeed = 8f;

// Use this for initialization
void Start () {

    cinematicCameras [activeCamera].SetActive (true);
	nextCamera = activeCamera;

}

// Update is called once per frame
void Update() {

    // If the start game key has been pressed...
    if (gameStarted == false && Input.GetKeyUp(KeyCode.Space)) {

        // ...deactivate cinematic cameras
        cinematicCameras[activeCamera].SetActive(false);

    } else {

        // otherwise, cycle through the cameras.
        CycleCameras();

    }
}

private void SwitchCamera(int cameraIndex) {

	if (cameraIndex != activeCamera) {

		// If the screen fade is less then (almost) full black...
		if (screenFader.color.a <= 0.998f) {

			// ...then continue lerping the screen fader towards black.
			screenFader.color = Color.Lerp (screenFader.color, Color.black, fadeSpeed * Time.deltaTime);

		} else {

			// ...set the screen fader to black.
			screenFader.color = Color.black;

            // Change the active camera
            cinematicCameras[activeCamera].SetActive (false);
			activeCamera = cameraIndex;
            cinematicCameras[activeCamera].SetActive (true);

		}

	} else {

		// If the screen fader is not close to completely clear...
		if (screenFader.color.a <= 0.002f) {

			// ...then continue lerping the screen fader towards clear
			screenFader.color = Color.Lerp (screenFader.color, Color.clear, fadeSpeed * Time.deltaTime);

		} else {

			// ..set the screen fader to clear.
			screenFader.color = Color.clear;

		}
	}
}

private void CycleCameras() {
    
    // Increment a timer to count up to restarting
    timer = timer + Time.deltaTime;

    // If the timer reaches the restart delay...
    if (timer >= timerDelay) {

        // Then reset the timer
        timer = 0f;

        // Choose the next camera
        nextCamera++;

        // If the next camera is greater then the highest index in the camera list...
        if (nextCamera > cinematicCameras.Count) {

            // ...then reset to the first cinematic camera.
            nextCamera = 0;

        }
    }

    // Switch to the next camera.
    SwitchCamera(nextCamera);

    }

Some advice would be appreciated, tnx

I’ve solved it actually.

Changed back to the original script were the player camera was in the camera list but selected only after the start of the game. My problem was that the GameManager script had public bool gameStarted = false and the cameraManager couldn’t access it, so I’ve changed it to public static bool and now it works