Hey guys. I’m trying to make a Day Night Cycle so that when i start the game It will start the cycle. I want it so that when the time variable is “6” then it will be at 6 o’clock. I also want it so that it is smooth. I am als trying to make it possible to be able to reference it from another script but that can be done later. Thanks in Advance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DayNightCycle : MonoBehaviour {
public float time = 0f;
public Transform Sun;
public Transform Moon;
public float counter = 0f;
private Quaternion targetRotation;
public float smooth = 1f;
// Use this for initialization
void Start () {
time = 0f;
}
// Update is called once per frame
void FixedUpdate () {
counter += 1*Time.deltaTime;
if (counter >= 10f) {
transform.Rotate = Quaternion.Lerp(time, 0f, 0f);
time += 1f;
Debug.Log ("Hi");
counter = 0f;
}
counter += 1*Time.deltaTime;
}
}