Search Unity

Question Blinking Text while Time.timeScale = 0f

Discussion in 'Animation' started by Deleted User, Apr 3, 2023.

  1. Deleted User

    Deleted User

    Guest

    How can I make the animation continue while time is stopped?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    5.  
    6. public class BlinkingText : MonoBehaviour
    7. {
    8.     public TMP_Text gameoverText;
    9.  
    10.     void Start() {
    11.         StartCoroutine(GameOverFlickerRoutine());
    12.     }
    13.  
    14.     void Update() {
    15.         Time.timeScale = 0f;
    16.     }
    17.  
    18.     IEnumerator GameOverFlickerRoutine() {
    19.         while(true) {
    20.             gameoverText.text = "GAME OVER";
    21.             yield return new WaitForSeconds(0.5f);
    22.             gameoverText.text = "";
    23.             yield return new WaitForSeconds(0.5f);
    24.         }
    25.     }
    26. }
    Thanks!
     
  2. Lifee00

    Lifee00

    Joined:
    Apr 13, 2021
    Posts:
    86
    The animator by default uses scaled time. Click on update mode > Use Unscaled time. That should work.

    EDIT: Oh my mistake, it's a couroutine, wait for seconds uses scaled time. Instead use wait for real seconds, which doesnt use scaled time.
     
    Last edited: Apr 4, 2023