- Home /
My simple math operation is returning infinity and I can't figure out why.
I'm having an issue that I can't quite pin down. I'm trying to lerp the orthographic size of the camera over a set number of seconds ( slowSizeDuration), but my counter for the lerp function (slowSizeTimer) is only returning infinity. slowSizeTimer is initialized to 0.001f in start.
if(slowSizeTimer > slowSizeDuration && slowSize == true){
slowSize = false;
}else{
slowSizeTimer += (Time.deltaTime/slowSizeDuration);
Debug.Log(slowSizeTimer + " - " + Time.deltaTime + " - " + slowSizeDuration + " - " + Time.deltaTime/slowSizeDuration);
}
The Debug Log shows this every frame: Infinity - 0.02 - 5 - 0.004
Can you share how and where you're setting slowSizeDuration? Is it int or float? The two possible reasons that spring to $$anonymous$$d are: 1) It is set to zero somehow (either not initialized in code, or set zero in the inspector) 2) It is defined as an int or calculated as an int / int division which is getting rounded down to zero.
Answer by tormentoarmagedoom · May 11, 2018 at 06:01 PM
Good day.
If slowSizeTimer is giving infinity, slowSizeDuration is causing it. And we dont see where it comes from.
Thanks, the apparent issue was that slowSizeDuration was initialized to 0 and continued to be computed as such, even after the value was changed in a later function call.
Your answer
Follow this Question
Related Questions
Displaying Time left 1 Answer
Using Time.deltaTime as time counter. 1 Answer
How to limit an effect to a certain duration 2 Answers
is Time.deltaTime dependent on computer speed? 2 Answers
Time.deltaTime Too Variable 0 Answers