+1 vote

how to make day and night cycle time?
for example i want 1 day = 16 minute, 8minute at day and 8 minute at night.
what should i do? how should i do?
should i use timer?

in Engine

+1 vote

The way I've done this..... I use a Singleton (Autoload) script and create my variables....

gameYear
gameMonth
gameDay
gameHour
gameMinute
gameSecond

And my main game scene has a timer. On timeout... the seconds increment, which spill into the minutes, then hours, days, years, etc. I can get more detailed with this if you need.

You could make this increment to the next value anyway you want and also you can adjust the Timer interval so a second is however long you feel it should be.

by (133 points)

thanks, that would be nice if you can give more detail

I'll Pseudo-code it for you....

(so don't direct copy / paste - it wont work)

extends Node

var gameyear = -10000
var gamemonth = 1
var gameday = 1
var gameminute = 1

### var gamesecond = 1

MAIN GAME SCENE
\$Timer1 (enabled, internval say... 1 second to start, adjust as needed)

Connect the timer to it's method...
func onTimer1_timeout():

Singleton.gamesecond += 1

if Singleton.gamesecond >= 60:
Singleton.gamesecond = 0
Singleton.gameminute += 1

if Singleton.gameminute >= 60:
Singleton.gameminute = 0
Singleton.gamehour += 1

if Singleton.gamehour >= 24:
Singleton.gamehour = 0 #or 1? Depends how you want to id your hours)
Singleton.gameday += 1

if Singleton.gameday >= 30: #30 days in your game's month?
Singleton.gameday += 1
Singleton.gamemonth += 1

etc. etc. etc.

### Let me know if you need more help.

thanks, i learn allot from your code,
i will :)

No worries, lots of folks have helped me on here.

I'm unavailable for a few days - till next week - but shout if you need more help with this, I will get back to you.