Hi Guys,
I’m following a book, Unity 3.x Game Development by Example Beginner’s Guide by Ryan Henson Creighton.
I managed to create a digital timer, and a time bar & round timer clock using OnGUI 2D textures. I’m trying to animate a pocket clock timer; the minute & second hands will move accordingly with the time limit. But I’m stuck.
The issues I’m having is that
I only only animate with one hand (sec). E.g even 80sec or 20sec it will reflect as 60sec in the texture itself
-
How do I animate the minute & second hand of my pocket clock?
var centerPoint: Vector2 = Vector2(pieClockX + pieClockHalfW, pieClockY + pieClockHalfH);
var startMatrix : Matrix4x4 = GUI.matrix;
function OnGUI()
{
var minutes :int;
var seconds : int;
var timeStr : String;
minutes = timeRemaining/60;
seconds = timeRemaining % 60;
percent = timeRemaining/startTime * 100;var secRot : float = (percent/100) * 360; // *** THIS ONE GUI.DrawTexture(clockRect2, pocketclock, ScaleMode.StretchToFill, true, 0); GUIUtility.RotateAroundPivot(-secRot, centerPoint2); GUI.DrawTexture(clockRect2, longstick, ScaleMode.StretchToFill, true, 0); GUI.matrix = startMatrix; // if this is off, the whoel thing is rotating
}
I tried other methods, but I end up having 70sec going from 50th (backward) moving clock wise)
And once past 60th/0 it went for a jump of 10sec
Below is the jump 10sec coding:
percentSec = seconds/startTime * 100;
var secRot : float = (percentSec/100) * 360; // **** THIS ONE
2)Why is the sudden jump of 10sec?
I tried to break the logic into smaller parts, but it’s still very confusing to me. I couldn’t make sense out of it. If possible, can explain to me how do I break into smaller parts.
Thanks!