I want to make a Day and Night that will start at a random time of day whenever a level beings, but will also automatically switch off lights on lampposts when it is day time. I’ve looked at so many tutorials only and they’re either too simple, or far too complicated for me. It doesn’t need to look nice or anything, since my game is top-down. I just want a day night cycle that changes the lighting of the level and casts shadows, but I don’t want to it start at the same time every time you play.
Thanks in advance.
Im not that good with coding but i think you’d have a public time/cycle script and another script on lamp posts getting the info from the time script and just tell it “if evening, turn on” “else turn off” or anything like that i imagine
I have no idea how to do that XD. I’m new to Unity and C#. I only ever previously used Gamemaker Studio and Unreal Engine 4 (with Blueprints). I’m trying to broaden my knowledge on different game engines, whilst also learning some C#.
This shouldn’t be too hard, but you need some basic knowledge of trig (something very commonly used in game development). For a circular motion like the orbit of a light around a scene, you’ll want to use Mathf.sin (tutorial on this here and further indepth on trig here), and then you can change the rotation of the light using Transform.LookAt(baseplate of your scene). The time variable will be plugged into sin, and can be incremented via something time based, so possibly an IEnumerator or InvokeRepeating. The rest is up to you, and just basic problem solving I’m confident you can do, good luck!