Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strange Countdown Problem

Discussion in 'Scripting' started by Ceylan12, Sep 17, 2020.

  1. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    I have float value which starts from zero. After lights go out I'm starting to increase float within update function. Float +=Time.deltaTime and after clicking to screen stopping increase and showing it at the screen. Everything work good.
    But there is some strange thing. %70 probably I have 0.267 and 0.284 second reaction time. My cousing has 0.333. I dont know if its different thing about engine or C#. What can be reason of that ? :);)
     
  2. adehm

    adehm

    Joined:
    May 3, 2017
    Posts:
    369
    Not sure I understand what you are saying. The cpu cycles can be inconsistent and therefor you are going to see inconsistencies of time between frames; that is actually the reason why you use Time.deltaTime.
    Floating point numbers are also inconsistent when the value is changed and that is why you always need to check >= or <= when comparing them.
     
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,888
    Can you rephrase your question, I also don't understand it. What is your code supposed to be doing and how is that differing from what you're seeing?
     
  4. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank you for answer, I will explain again.
    I have float which is 0 at start. It's increasing with time.DeltaTime at update function. After light at game disappear user touching screen, float is stop increasing and showing at screen. I'am trying and I'm getting 0.267 second always (like %80). I don't know If Is it design thing at default libraries.
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,888
    It could just be that your device (what kind of device is it?) has very consistent framerates, and your reaction time is pretty consistent. One thing you can try is to also have an integer counter, and increment by 1 each Update to count the frames. See if the number of frames that has passed is also consistent.
     
  6. Ceylan12

    Ceylan12

    Joined:
    Dec 24, 2016
    Posts:
    113
    Thank you for answer. I will check it. My device is android phone. (Xiaomi Mi8)