I’m attempting to get a clock tower to rotate it is analog time in response to the precise time.
Nonetheless, the mesh or supplies will not rotate utilizing the “DateTime.Now.TimeOfDay;
hours.localRotation =
Quaternion.Euler” methodology. It stays nonetheless. Can anybody please assist?
Code:
non-public const float
hoursToDegrees = 360f / 12f,
minutesToDegrees = 360f / 60f,
secondsToDegrees = 360f / 60f;
public Remodel hours, minutes, seconds;
public bool analog;
void Replace()
{
if (analog)
{
TimeSpan timespan = DateTime.Now.TimeOfDay;
hours.localRotation =
Quaternion.Euler(0f, 0f, (float)timespan.TotalHours * -hoursToDegrees);
minutes.localRotation =
Quaternion.Euler(0f, 0f, (float)timespan.TotalMinutes * -minutesToDegrees);
seconds.localRotation =
Quaternion.Euler(0f, 0f, (float)timespan.TotalSeconds * -secondsToDegrees);
print(timespan);
}
else
{
DateTime time = DateTime.Now;
hours.localRotation = Quaternion.Euler(0f, 0f, time.Hour * -hoursToDegrees);
minutes.localRotation = Quaternion.Euler(0f, 0f, time.Minute * -minutesToDegrees);
seconds.localRotation = Quaternion.Euler(0f, 0f, time.Second * -secondsToDegrees);
}
}
}