# Have an animated clock keep time?

Just throwing this out there as a wondering if it’s possible to do and if so how complicated it would be?

I’ve made an animated “Kit Cat Clock” you know the kind that looks like a cat with the swinging tail and eyes that go back and forth lol

What I thought might be a cool idea is if the clock could somehow be made to actually keep time? Lets say that after a player has been playing for a while and they look at the clock on the wall that the hands of the clock have actually moved the correct amount of time that the player has been playing for. That would be cool… especially if the clock displayed the time that was on the users computer acurately.

like I say I’m not very good with code and I’m just wondering if it could be done and if so how complicated it would be to do?

The clock has an animation for the eyes and tail but the hands of the clock although they are rigged (Have bones for the Hands) The hands themselves do not have any animation attached, I’m assuming a script would articulate them… dunno??

It certainly can be done and should not be too difficult. You can use System.DateTime.Now to get the current time as a DateTime object.
Then all you have to do, is adjusting the clock hands rotation according to the minutes and hours of your current time.

it could look somewhat like this:

``````System.DateTime currentTime = System.DateTime.Now;
int minutes = currentTime.Minute; // value between 0 and 59;
int hours = currentTime.Hour%12; // currentTime.hour is a value between 0 and 23 so we have to adjust it for a 12 hour display

float minuteRotation = (minutes/60f)*360; // minute hand rotation in degrees
float hourRotation = (hours/12f)*360 // hour hand rotation in degrees
``````