Hello Stack overflow community, im actually a beginner in scripting and try to explain my problem as good as possible. please be patient with my try of explanation :)
the situation is the following...
i have a float var "energy" for example and on every fixed update it loose some of the energy over time "energy drain" using time.deltatime
my goal is to calculate how many seconds left before the value "energy" hits 0.0f
it would be nice if someone can answer me with a link to an example or write down some pseudocode.
thank you in advance
CodePudding user response:
I assume you are doing something like
energy -= energyDecreasePerSecond * Time.deltaTime;
so you mean something like
var secondToGo = energy * energyDecreasePerSecond;
CodePudding user response:
I assume you are doing something like
energy -= energyDecreasePerSecond * Time.deltaTime;so you mean something like
var secondToGo = energy * energyDecreasePerSecond;
-derHugo
you want to divide by energyDecreasePerSecond instead
var secondToGo = energy / energyDecreasePerSecond;
