Achievement UI Pop up system at race finish

In a race, at finish line, i would like to show UI panels with the achievements: for example: you finish 1st, you get all coins, you have done a new time record, etc… But not always i don’t know when i’ll do this goals. I’ve tried this with coroutines, to show each panel for 2 seconds.
Cubes simulates the UI advs.
The example show that you’ve 3 goals at first, but when finish (finish line) you only get two of them (start_CheckAdvs). Only have to hide the first and third cube in two seconds.

   using System.Collections;
   using System.Collections.Generic;
   using UnityEngine;

       public class Coroutine : MonoBehaviour
      {    
       public GameObject [] Adv; //UI panels for coroutine afer cross the finish line
       public GameObject cube_01, cube_02, cube_03;   //UI panels
  void Start()
   {
     Adv = GameObject.FindGameObjectsWithTag("Achievement_Adv");
     cube_01.SetActive(true);
     cube_02.SetActive(true);
     cube_03.SetActive(true);
   }
 
 void Update()
 {       
     Invoke("finishLine", 1f); //Achievements at finish line
     Invoke("start_CheckAdvs", 1.4f); //Chek which goals you get
     Invoke("stop_CheckAdvs", 2f); //Stop Chek goals
     Invoke("FinishAdvs", 4f); //Start Coroutine of your goals
 }
 void FinishAdvs()
 {
     StartCoroutine(hideAdvs());
 }   
 void start_CheckAdvs()
 {
     StartCoroutine(check_Advs());
 }
 void stop_CheckAdvs()
 {
     StopCoroutine(check_Advs());
 }
 IEnumerator check_Advs()  // To know how many goals you've done
 {
         yield return new WaitForSeconds(1f);
         Adv = GameObject.FindGameObjectsWithTag("Achievement_Adv");
         yield break;        
 }
 IEnumerator hideAdvs() // The goals you achive at this race will desappear
 {
     yield return new WaitForSeconds(2);
     Adv[0].SetActive(false);
     yield return new WaitForSeconds(2);
     Adv[1].SetActive(false);
     yield return new WaitForSeconds(2);
     Adv[2].SetActive(false);        
 }
 void finishLine() // At finish Line, you've done only 1st and 3rd goal
 {
     cube_01.SetActive(true);
     cube_02.SetActive(false);
     cube_03.SetActive(true);
 }
 }

Thanks in advance.

Hi, sorry for the late reply.
i have seen some little terrorism in that code.

  1. avoid. using findObjectbytag/name etc
  2. Use coroutines instead of “invoke”, you have much better control over it, invoke is the cheap solution.
  3. Why woud you want to use that invokes in the update? you want them to run always?
  4. when you yield a value, and its always the same, consider creating a variable and yielnd it instead of creating a new one every time, specially if you are doing that in the update method.

I hope it helped you