Nitpicking about Time.time and cycles

Hi, I found something rather interesting

I know this is not a real issue but the way cycles are calculated by using time / cycleSpeed is constantly increasing the end result because time itself is increasing.

Just for fun if you type something ridiculous small values there like 1e-37 and log cycle values you’ll see that the value gets too big and breaks the whole thing.

Instead of just using this formula
cycles = time / cycleSpeed;

I tweaked it a little and used modulo (remainder) to fix this issue
cycles = time % cycleSpeed / cycleSpeed;

Note: My variable names are probably different than in the lecture but you should guess which line I’m talking about.

Anyways, with that fix I can happily put values like 1e-37 to my “design lever” and say that this is what I want.

EDIT: Celebrating too soon. It seemed to work but because it’s ridiculously fast now (the movement of the obstacle) I can just fly through it. Collision detection doesn’t work. Well, I don’t blame Unity on that :smiley:

EDIT 2: Well actually collision detection works just fine even with that speed. The problem was that I had my box aligned wrongly in z axis and it was just behind the rocket… I don’t know when that happened to me. I must have accidentally changed it and when when going nuts with that speed I couldn’t even tell visually that it was on background. Part of the learning I guess :smiley:

Privacy & Terms