- Home /
How I can increase num 1 to num 2 in x time?
How can I make a program to calculate num 1 to num 2 in x time? So if I say I want go 1 to 3 in 1 sec can I somehow do it so unity says every time when it loads update to calculate the time between and after 1 sec it goes to 3.
Comment
You want the increase to be gradual? or just snap from 1 to 3 after one second?
Best Answer
Answer by Kaskorian · Oct 21, 2017 at 09:31 AM
I do not know if that's what you mean, but you can increase your value by Time.deltaTime. This increases the value by 1 in a second. For a different result, multiply Time.deltaTime by a factor. For a factor of 0.5f, increase the value by 1 every 2 seconds.
value += Time.deltaTime * factor
you can calculate the factor like below: factor = 1 / secondsInWhichTheValueIncreasesByOne