user3182651 user3182651 - 1 year ago 122
C# Question

Tycoon like game time and date Unity5

I am creating a tycoon like game and am not sure how to do the date and time on the game son right now when a new game is created I get the date for now using System.DateTime.Now and show it on a UI Text but from now on on the game how should the date and time go by of course it shouldn't increase by real time what am exactly trying to do is like how RollerCoasterTycoon World time go by

So it will be like 5 min in real life will go full day in the game so for example if I started the game now its 10/Sep/2016 after 5 min in real life it will be 11/Sep/2016 in the game and so on.

Answer Source

I think you've just answered your own question. You can just multiply each frame by how fast you would like your time to go. If you want your game to be 2 times faster you just multiple Time.deltaTime by 2 and assign it to your time variable. I would advise you read about day/night cycle, because you will probably want to implement visual effects of changing time, like seasons.

Edit: Because game can sometimes run faster or slower I would increment your time each second not frame. So first in your Update method you create something like timeElapsed += Time.deltaTime and

if (timeElapsed > 1)
    timeElapsed = 0;
    gameTime.AddSeconds(1 * gameSpeed);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download