Real life day-night cycle
I know, it sound wierd, but i want my game to have a day-night cycle, that would be EXACTLY the same as the real one. You look out of window, its night, you look to game, its night.
I dont know if only rotating directional light is enough to get a great effect...
Thanks for help ;)
Answer by HenryStrattonFW · Jan 31, 2017 at 01:56 PM
You would likely do a little more than just a rotating directional light. I've never done this sort of thing before, but here's how my brain approaches it at a quick glance.
Rotating lights as you said, but ensuring the colour, intensity and direction reflect the changes of the day/night cycle, so the day light might fade in intensity towards the end of the day, whilst another light starts ramping up from the other direction this light would be a colder blue light (or other depending on your scene).
You would also likely want to consider shifting the ambient colour, or skybox would want to somehow transition from a day to night scene as well.
There are all sorts of other things you may wish to do like shifting a more night appropriate ambient sounds etc. But it really depends on what game you're making, the style, etc.
Yeah, i know that. I dont need to change the skybox, because there is no skybox :D The part i need to know, is getting info about time in day... ( or even live weather ) But i dont think its possible...
Oh i see, my apologies I misunderstood what part of this you were looking for. Well for the weather you would need to rely on a 3rd party service. I'm sure there are various services out there that would support some sort of API for weather data, but wouldn't have a scooby about that myself.
As for the time of day, that's very possible. You can use System.DateTime.Now for this, which gives you a DateTime object based on the current time/date settings on the system your game is running on (Granted users may have set their machines to not be accurate time/date but its quite unlikely and so this is probably a perfectly acceptable thing to base it on).
Oh thanks a lot!!! I did some math to map the 86400 to 360 and now it works!!!! thank you!
Answer by Lord_meow_Sambo · Jun 30, 2019 at 12:29 PM
Hi there,
Just wondering what maths/code would I write to make this all work?
My game has planets and I want to make one of them a real world time.
Thanks.
What code would I type for C# to make it work and is it easy yo offset the time if I have a planet that is an hour behind?
Your answer
Follow this Question
Related Questions
effective lighting for moon (for a day night cycle) 0 Answers
Is there an ETA for Mixed Lighting on directional specular GI? 0 Answers
Google Play Realtime MP - Punish player who leaves room. 0 Answers
RealTime Lighting on Heavily Moving Environment: A Trick to Make it Happen (Maybe) 0 Answers
Directional Light Problem 0 Answers