clock second smooth movement

Hi,
I’m trying to get an animated second hand to move smoothly rather than ‘tick’ every second, do i add Time.deltaTime somewhere - not sure how to calculate that but i have the tick working so far:

currentTime = System.DateTime.Now;

var seconds : float = currentTime.Second

rotationSeconds = (seconds/60f)*360;

handSeconds.transform.localEulerAngles = new Vector3(0, 0, rotationSeconds);

1 Answer

1

DateTime.Second is an int - you need to do:

C#

 var rotationSeconds = ((float)(currentTime.Second+ currentTime.Millsecond/1000f)/60f ) * 360;

JS

var rotationSeconds : float = ((currentTime.Second+ currentTime.Millisecond/1000f)/60f ) * 360;

thanks I can see what you've done but it doesn't work properly. how do i change the source which is an int to a float but do this by calculating 360 rotation over 60 seconds instead of reading a different measure of time as the source?

–

Ah sorry, mind was obviously wandering - updated the answer now.

–

That's it! little corrections: var rotationSeconds : float = ((currentTime.Second+ currentTime.Millisecond/1000f)/60f ) * 360;

–

Sorry mine was C# :P

–

I really was losing it today...

–