Today to write a small clock, in fact, very easy, applied to the Euler angle.
First create clocks, minutes, seconds, and 4 points (12, 3, 6, 9) Lazy ~ ~ did not make so many points.
Clocks, minutes, seconds the center of the three parent must be aware that we are rotating the Euler angle of the parent.
(The center of the parent is at the vertex of the child)
Next we'll write the code. For example, the following:
Using unityengine;using System.collections;public class Clock:monobehaviour {public Transform shi; public Transform Fen; Public Transform miao;//with this for initializationvoid Start () {}//Update is called once per framevoid update () {
debug.log ("Time" +system.datetime.now.hour); Debug.Log ("min" +system.datetime.now.minute); Debug.Log ("Seconds" +system.datetime.now.second); Second float miaonum=system.datetime.now.second*6f; Miao.eulerangles = new Vector3 (miao.position.x, MIAO.POSITION.Y,-miaonum); Min Float fennum = System.DateTime.Now.Minute * 6f; Fen.eulerangles = new Vector3 (fen.position.x, FEN.POSITION.Y,-fennum); Hours Float shinum = System.DateTime.Now.Hour * 6f; Shi.eulerangles = new Vector3 (shi.position.x, SHI.POSITION.Y,-shinum);}}
all the values are *6. Because altogether 60 seconds, one lap is 360 degrees, 1 seconds is 6 degrees.
It's easier to write.
Let us not laughed at.
。
。
:
"Unity3d self-study record" Unity3d's homemade small clock