I have this system time reference script that I would like to change so that instead of doing something on hour it did it within a time range say between 8:00 to 12:00 noon.
How would I change the setting of this script so that it does that?
void Awake () {
if (sending == null) {
DontDestroyOnLoad (gameObject);
sending = this;
} else if (sending != this) {
Destroy (gameObject);
}
MessageCentreText.text = "CALIBRATE";
//Time OF Day Notification
//Noon Time
if (sysHour == 12) {
GetComponent<AudioSource>().clip = timeVoicesNoon[Random.Range(0,timeVoicesNoon.Length)];
GetComponent<AudioSource>().Play();
MessageCentreText.text = "GOOD AFTERNOON";
Debug.Log ("Good Afternoon!");
}
//Morning Time
else if (sysHour == 8) {
GetComponent<AudioSource>().clip = timeVoicesMorning[Random.Range(0,timeVoicesMorning.Length)];
GetComponent<AudioSource>().Play();
MessageCentreText.text = "GOOD MORNING";
Debug.Log ("Good Morning!");
}
//Night Time
else if (sysHour == 22) {
GetComponent<AudioSource>().clip = timeVoicesNight[Random.Range(0,timeVoicesNight.Length)];
GetComponent<AudioSource>().Play();
MessageCentreText.text = "GOOD EVENING";
Debug.Log ("Good Night!");
}
else{
//Do something if desired
MessageCentreText.text = "KNIGHT INDUSTRIES 2000";
Debug.Log("Go to bed!");
}
}
I had forgotten that if I change it to this it works within a certain range.
if (sysHour > 13) {
It’s not precisely between something like 8 Am and 11 Am but it works.