Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How Can I Make Invoke independent of Time.timescale ?

Discussion in 'Scripting' started by RyanGamingKob, Dec 25, 2019.

  1. RyanGamingKob

    RyanGamingKob

    Joined:
    Oct 27, 2019
    Posts:
    18
    I meant I want to use Invoke based on the real timing no the game time
    Take a look:
    Code (CSharp):
    1.  public void Resume()
    2.     {
    3.         //Resume the game
    4.         pauseMenuPanel.SetActive(false);
    5.         Invoke("timeUnFreeze", 3f);
    6.         isPaused = false;
    7.     }
    8.  
    9. public void timeUnFreeze()
    10.     {
    11.         Time.timeScale = 1f;
    12.     }
    so i want to resume the time after 3 seconds (in real time) of the click on the ResumeButton
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @RyanGamingKob

    Maybe use coroutine instead of Invoke and add Time.unscaledDeltaTime to your timer instead of Time.deltaTime, that way it isn't affected by timeScale that is set to 0.
     
    RyanGamingKob likes this.
  3. RyanGamingKob

    RyanGamingKob

    Joined:
    Oct 27, 2019
    Posts:
    18
    can i use Time.unscaledDeltaTime only? and how