Time Options

v4.0

Gametime is designed to be flexible and handle custom time periods. At this point, it does not handle more complex scenarios, so it may be worth noting that it does not handle:

  • The gregorian calendar or other real-world based calendars

  • Leap years

  • Months which have different numbers of days

  • Years which have more or less days than the number of months * number of days per month

With those limitations in place, the system does handle quite a bit. You can set these options in the Inspector.

A value of 1 in Gametime = 1 "in game minute". The private float _subCounter is used at runtime to keep track of the amount of in-game time that has passed between each minute.

The float secondsPerGameMinute determines how many real-world seconds pass for each in-game minute. A value of 3.0f means that every real-world minute, 20 in-game minutes will elapse.

public bool useAmPm = true; // When writing out the time
public bool monthDayYear = true; // If false, will do Day/Month/Year
[Range(0.5f, 100)] public float realTimeSecondsPerGameMinute = 3.0f; // Real-world seconds per in-game minute
[Range(1, 240)] public int secondsPerMinute = 6-; // In-game seconds per in-game minute
[Range(1, 240)] public int minutesPerHour = 60; // In-game minutes per in-game hour
[Range(1, 240)] public int hoursPerDay = 24; // In-game hours per in-game day
[Range(1, 240)] public int daysPerMonth = 30; // In-game days per in-game month

// You can specify the start time for your project in the Inspector as well
// The values should always be within the ranges you set.
public int startingYear = 1288;
public int startingMinute = 30;
public int startingHour = 9;
public int startingDay = 15;
public int startingMonth = 5;

// The number of days in a week, months in a year, and seasons in a year, are
// determined by the number of names in these lists.
public List<string> dayNames = new List<string>();
public List<string> monthNames = new List<string>();
public List<string> seasonNames = new List<string>();

1 gameTime = 1 in-game minute

Now() and GameTime are very similar, but return slightly different things, for different use cases.

GameTime will return the int _gameTime, while Now() returns a float, and will include subTime by default.

subTime is the measurement of the seconds between in-game minutes.

Last updated