Hello, I’m trying to make a clock like the one in FNAF. I’m trying to make it so the levels in my game start at 12 AM, and end at 6 AM but can’t seem to understand how the concept or structure of the script is supposed to be used for this. The language I’m using is C#.
If I can get help or a script example as soon as possible, that would be great. Thank you!
Here is a snippet from a analog clock I build in a project once:
//*************************//
// Created by Manu Hanssen //
// BlueTea BV 2015 //
//*************************//
using UnityEngine;
using System;
public class Clock : MonoBehaviour
{
#region Variables
public GameObject LargeIndex;
public GameObject SmallIndex;
protected int Hours;
protected int Minutes;
#endregion
#region Unity Methods
protected void Update()
{
if (Minutes != DateTime.Now.Minute)
{
SetHours(DateTime.Now.ToLocalTime().Hour, DateTime.Now.Minute);
SetMinutes(DateTime.Now.ToLocalTime().Minute);
}
}
protected void SetMinutes(int minutes)
{
Minutes = minutes;
LargeIndex.transform.localEulerAngles = new Vector3(LargeIndex.transform.localEulerAngles.x, 360/60*Minutes, LargeIndex.transform.localEulerAngles.z);
}
protected void SetHours(int hours, int minutes)
{
Hours = hours;
int hoursToSet = Hours >= 12 ? Hours - 12 : Hours;
SmallIndex.transform.localEulerAngles = new Vector3(SmallIndex.transform.localEulerAngles.x, (360 / 12 * hoursToSet)+(360/12/60*minutes) , SmallIndex.transform.localEulerAngles.z);
}
#endregion
}
Feel free to use or modify it!