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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

I need a start up timer that starts as soon as the game does.

Discussion in 'Scripting' started by mkhazim, Apr 30, 2015.

  1. mkhazim

    mkhazim

    Joined:
    Mar 17, 2015
    Posts:
    4
    Script in C#. Timer in seconds. Timer stops as soon as win conditions have been achieved.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    Time.time?
     
    Kiwasi likes this.
  3. mkhazim

    mkhazim

    Joined:
    Mar 17, 2015
    Posts:
    4
    I wanted to make it so that when the song ends = game over. So how do I do that? Ignore the 1st request.
     
  4. CG_Echtzeitschmiede

    CG_Echtzeitschmiede

    Joined:
    Feb 19, 2015
    Posts:
    93
    Code (CSharp):
    1. public float songDuration = 180f;
    2.  
    3. void Update()
    4. {
    5.      if (Time.time > songDuration)
    6.            GameOver();
    7. }
     
    mkhazim likes this.
  5. mkhazim

    mkhazim

    Joined:
    Mar 17, 2015
    Posts:
    4
    Thank you!!!
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    A coroutine would be better.
     
  7. pws-devs

    pws-devs

    Joined:
    Feb 2, 2015
    Posts:
    63
    For such a simple thing, Invoke(<insert function name>) would be enough.
     
    Kiwasi likes this.