I'm learning Unity 5 and I know nothing about Programming. But I have watched a tutorial on "How to make a Day/Night Cycle" in Unity and the tutor wrote this script to cycle between moon and sun.. Here's the code:
using UnityEngine;
using System.Collections;
public class sun : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.RotateAround(Vector3.zero, Vector3.right, 1f * Time.deltaTime);
transform.LookAt(Vector3.zero);
}
}
And the speed of cycling is depends on 1F which we can change the any number.. But I don't know how long does it take to do 1F rotation between sun and moon! So can you tell me this number in something like seconds or minutes ? So I can be able to set it myself to a custom duration. Thanks in advance
In C#, a lowercase f after a number indicates that the value should be treated as a float.
https://msdn.microsoft.com/en-us/library/b1e65aza.aspx
By multiplying this by the deltaTime value, it's rotating either 1 degree or 1 radian per second. I'm unfamiliar with Unity and can't speak authoritatively on the subject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With