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. Dismiss Notice

Timing objects against the time scale?

Discussion in 'Scripting' started by Marscaleb, Jul 7, 2014.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    977
    I have been pausing the game by simply setting the time scale to zero. It works very well.

    However, I want to start timing some events when the game is paused, in other words, without regards to the time scale.
    For example, I have a "stage clear" event that needs to pause everything on the screen so that enemies don't continue to charge at the player. The easiest way to do this is simply set the time scale to zero to pause the game.

    But to actually start the next level, I am invoking a function to do just that, timed to execute once the music has finished playing.
    But if I put the time scale to zero, that invoked function will never be called.

    Is there some way I can tell a particular object/script to ignore timescale and just operate at normal speeds regardless of timescale?
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    I think they added in 4.5 "unscaledDeltaTime", which is the real time delta time.
     
    IvanAuda and DanielQuick like this.
  4. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    977
    Unscaled delta time sounds much easier to work with than the real time since start up.
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    There are a few unscaled options. Handy because I needed something similar recently.