I’m using Transform.RotateAround to rotate an object (directional light) around the center of the game world, to simulate a day/night cycle.
The trouble I’m having is I need the complete 360-degree rotation to take exactly 1140 seconds, so essentially I need the rotation to occur at 0.3157894736842105 per second.
So far my code looks like this (clockSpeed is a variable that determines the speed of the clock)
transform.RotateAround(Vector3.zero, Vector3.forward, (cm.clockSpeed * 0.3157894736842105f) * Time.deltaTime );
This feels close but it’s off somewhere, out of sync. If anybody could point me in the right direction, I’d greatly appreciate it.
Edit: clockSpeed is a variable that determines how many game-clock ‘minutes’ are passed with each second. The clock is more or less the following code:
void updateGameClock() {
if (clockRunning) {
cmtime = cmtime.AddMinutes(clockSpeed);
clock.text = cmtime.ToString("dd MMM hh:mm tt");
}
}
void startGameClock() {
clockRunning = true;
clockSpeed = 1f;
InvokeRepeating("updateGameClock", 1, 1F);
}