Hi,
Thank you for your questions. ![]()
The name fillFraction indicates that we are dealing with a fraction: x / y. We use the fillFraction to display an image. This means that we need values from 0 (0%) to 1 (100%).
At the start of our game, we execute this line of code: timerValue = timeToShowCorrectAnswer;.
Let’s say that the value of timeToShowCorrectAnswer is 30f. This means that timerValue is 30f, too, at the start of our game. If timeToCompleteQuestion is 30f as well, timerValue / timeToCompleteQuestion == 1f because 30f / 30f == 1f. fillFraction would be 100%.
The next thing I dont understand is how were able to set the timerValue to the timeToShowCorrectAnswer but also have it equal to what time.deltaTime is?
We do not set it equal to Time.deltaTime. We subtract Time.deltaTime from the value.
timerValue -= Time.deltaTime; is the same as timerValue = timerValue - Time.deltaTime;. Programmers don’t like to type lengthy code, so we have a lot of so-called syntactic sugar.
Each frame, we execute this line: timerValue -= Time.deltaTime;. This means that our fillFraction value decreases each frame.
Did this clear it up for you?
See also:
- Forum User Guides : How to mark a topic as solved