initial commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DayNightCycle : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Duration of a full day in seconds")]
|
||||
public float secondsPerDay = 120f;
|
||||
|
||||
private float rotationPerSecond;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Calculate how many degrees the light should rotate per second
|
||||
rotationPerSecond = 360f / secondsPerDay;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Rotate around the X-axis
|
||||
transform.Rotate(Vector3.right, rotationPerSecond * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user