Digital Clock sync with Sun Rotation

Hello to anyone reading.

I am Still new to scripting. And need your candor.
I am trying to achieve a digital clock sync with game time (day night cycle)

i have been trying to learn Via tutorials. But there are none about that particular subject. I have found a lot about
Real-Life Time. But none for in-game time.

Also Should i make one script seperate instead of merging 2 in one?

here’s what i got so far (for my rotation)

True, that’s a very specific wish and not something you’d find a tutorial for.

But you should do lots of other tutorials, until you have built up your skills to the point where something like this is easy.

There really isn’t much to it — you just define what “game time” is, and make some (probably singleton) script to manage it. And then you have both your digital clock script, and whatever is displaying your day/night cycle, read the game time from there.

I’m not sure what you’re referring to. Your game will have LOTS of scripts by the time you’re done. When you go through those tutorials I mentioned, you will see how more experienced Unity devs tend to divide them up.

You’ve got a Pastebin link? If you put your code here, I would actually look at it. :slight_smile:

So the general idea is that you have to convert the time of day into degrees so that you can rotate the sun correctly.

As Joe said for a heads up in next posts, you can display code directly in your post.

Your code looks good, except make sure you put brackets for your for loop
You also didn’t include cnt in your stars code. Is there a guaruntee that the same number or suns and stars are in your system?

Edit: I didn’t check your math, so I’m not confirming it’s perfect.

 for(int cnt =0; cnt < sun.Length; cnt++)
        sun[cnt].Rotate(new Vector3(_degreeRotation, 0, 0) * Time.deltaTime);
        stars[0].Rotate(Vector3.left * Time.deltaTime);

// Switch to

for(int i=0; i<sun.Length; i++){
        sun[i].Rotate(new Vector3(_degreeRotation, 0, 0) * Time.deltaTime);
}
for(int i=0; i<stars.Length; i++){
        stars[i].Rotate(Vector3.left * Time.deltaTime);
}

well i dont want Stars as the same speed as Sun. so i left it as is.

TBH, i just found a Tutorial about the matter. but the problem is. i need a way to use it with my rotation.

. ( i don’t know if youtube link is allowed here). But here goes. I will try to find a way to link my rotation to this tutorial. And let you know what i have.