- Home /
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);
Answer by whydoidoit · Mar 30, 2013 at 03:52 PM
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 ins$$anonymous$$d of reading a different measure of time as the source?
Ah sorry, $$anonymous$$d was obviously wandering - updated the answer now.
That's it! little corrections: var rotationSeconds : float = ((currentTime.Second+ currentTime.$$anonymous$$illisecond/1000f)/60f ) * 360;
Your answer
Follow this Question
Related Questions
How do you display the Time? (as in you're PCs clock) 1 Answer
Smaller Time Interval? 3 Answers
Help with a faster clock? 1 Answer
Visual timer? Like CUT THE ROPE 2 Answers
Programming Accurate Clock Hands 1 Answer