Invoke delay scnene Change

Hello im kinda stuck i try to delay the scene load after i collected 4 points.
would be nice if i can get some help.
my code so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class WinConditionCam1 : MonoBehaviour
{
    [SerializeField]
    private string _Scene_1 = "Scene_1";
    int Score;
    public Text MyText;
    private int score;
  
    private void Start()
    {
        Invoke("Loadtimelevel", 2);
        MyText.text = "";

      
    }

    void Loadtimelevel()
    {
        if (Score == 4)
            SceneManager.LoadScene(_Scene_1);
    }
    void Update()
    {
        MyText.text = "SYSTEM FAILURE:" + score + "/4";

     
    }
  
    void OnTriggerEnter(Collider point)
    {
     
        if (point.CompareTag("Point"))
        {
   
       
            Debug.Log("error happenend");
         
            Destroy(point.gameObject,1);
         
            score = score + 1;
            Score++;
        }
    }
}

You can use coroutines to wait.

I have a generic solution you can use here:

1 Like

Thanks you! it solved my problem.

1 Like