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

Get the value of time

Discussion in 'Scripting' started by maxrio, Nov 19, 2015.

  1. maxrio

    maxrio

    Joined:
    Jan 8, 2015
    Posts:
    25
    Greetings. How can I get the value of time at a certain time and store in a variable using Time.time? For example: 3:23 min to save this value only in the variable timeNow.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    Code (csharp):
    1. float timeNow = 0f;
    2. void Update() {
    3. if (Input.GetKeyDown("t") ) timeNow = Time.time;
    4. }
     
    maxrio likes this.
  3. maxrio

    maxrio

    Joined:
    Jan 8, 2015
    Posts:
    25
    Thank you.