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

capture/record data between interval

Discussion in 'Scripting' started by bobbytan93, Jan 6, 2015.

  1. bobbytan93

    bobbytan93

    Joined:
    Jan 5, 2015
    Posts:
    2
    Hi,
    Anybody know how to measure and record data in between interval?

    let's say i am using unity to create a numbering tapping game and there's 4 numbers (1,2,3,4) and they are all in box form. and i want to know how long it take for player to tap one number after another? want to measure and record the interval/inbetween time player take to tap from number 1 to 2, 2 to 3.

    new to this unity software, hope to seek some help for this project. thank you : )
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    When the user makes the first tap, record t = Time.time. When the user taps again, you have (Time.time - t) as the time between taps.
     
  3. bobbytan93

    bobbytan93

    Joined:
    Jan 5, 2015
    Posts:
    2
    hi sir, then may i know where should i put this code under?
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,377
    In a script.

    You'll need some variables to store these values in. I'd probably have some List or Stack object to store the values in as they get pressed. As well as a var representing which key we're waiting for.

    In the Update event you'd then test if the next value was tapped.

    If it were, you'd record the time, and set the var for the next value to listen to to the next value in the order.
     
    Graham-Dunnett likes this.
  5. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Guess you need to follow the Learn tutorials that give you a basic kick-start in c# programming.