This is the first way in which you can set up a simple time system, it is quicker than the latter but has less flexibility on specific times of day. If you are simply after an event that can turn your game from night to day then this is for you, if you want an event that can run hourly time with the ability to implement switches at virtually any time of the day, then click here.
Setting up your very own time system using events is incredibly simple and this tutorial is going to be very short. More importantly, I will then go onto explain the various things you can do to make your time system more relevant.
Decide how long you want a day to last...
This tutorial assumes that you are going to use a simple 24 hour, 7 day system. I'm currently not implementing seasons because that makes things a little more complicated and for another important reason. Check out the very bottom of this tutorial to see why. So I've decided to take a leaf out of The Sim's book and consider a minute to be a second and therefore...an hour to be a minute. More importantly, this means that for every 24 minutes...we have a day. Now that we know how long our day is going to last, it's time for step 2.
Break up your day...
Throughout the day, we see certain changes. Sunrise to morning, morning to noon, noon to afternoon, afternoon to dusk and dusk to night. The cycle repeats but you need to consider when all of these events happen. The best thing to do (if you want it to be realistic) is to wait until tomorrow...note down what time the sun comes up (roughly), what time is starts to heat up, what time it starts to cool in the afternoon and what time the sun sets. This can be to the closest 15 minutes or to the hour, it's really up to you. I'm going to say that the sun rises at 4am, it starts to get warmer at 11am, it starts to cool at 3pm and gets dark at 8pm. Now for the difficult bit...calculating the conversion from the normal day to your game's system time.
I'm assuming that every day is made up of 24 minutes, each hour is a minute.
4am is 4 hours into the day...therefore it takes 4 minutes.
11am is 11 hours into the day...therefore it takes 11 minutes. I'm not going to repeat this because you should get the point by now.
You'll also need a good idea of the start time of your game...when does the game actually become playable?
This isn't really all that difficult but it would make sense to get these numbers down on paper. Now that you've done the number crunching...it's time to produce the script that's going to run this. If you've read my 'Weather System Tutorial then you'll know much of what I'm about to explain. Much like this other system, my time system revolves around a combination of checker and changer common events. One to watch the clock as it counts down and another to react to this change and restart a new clock. You'll see what I mean shortly.
Step 1:
The first thing you'll need to do is set up a common event. I have named mine 'First Day.' This event is simple in design and purpose. Essentially, this is the initial place-holder event, the commands that tell the game roughly what time it is that you will be starting, assuming of course that you are not starting at the beginning of a brand new phase. For example, I am starting my game at 10am...because 10am sits in-between the morning and noon phase, I have to create a new common event to handle the time difference. The event commands are as follows.
As you can see, the event is a simple parallel with the condition switch 'Time Start.' The timer begins with a countdown of 1 minute. Why 1 minute? Well if my game is starting at 10am, we must assume that it is in the morning phase because with 1 hour to go until the noon phase (which starts at 11am). Each minute represents an hour in game, therefore I need a minute countdown. Once this has been initiated, my event is no longer needed so I turn off Time Start and turn on Noon Check. Like I said previously, we've created an event to start the counter, now we need one to check the counter until it reaches zero, our checker event. Since the next phase will be noon, we're using the Noon Checker event.
Step 2:
We now need to create our Noon Checker event...a very simple task. The event will be set up with a parallel Trigger and this time, a condition switch of 'Noon Check' (the switch we just turned on).
As you can see, this checker event is designed to look out for when the timer hits zero and, therefore we have placed a conditional branch with the condition of a timer of 0 mins, 0 seconds or less. When this condition is satisfied (time has ran out) the Noon Check switch turns off (because we will no longer be using this checker until the noon of the next day) and 'Noon Change' comes on. 'Noon Change' is the switch we require to turn on the next event, Noon Changer which will be in charge of, as I have said, restarting the timer and of course, changing the game to noon, whatever change you may wish to implement.
Step 3:
Our final event, the Noon Changer is built in a similar way to our previous 'First Day' event and is simply designed to restart the clock and set the switches around again and change the time of day in whatever way you wish. It looks like this.
As you can see. the first thing to happen is the resetting of the timer. In this case, my timer is resetting to 8 minutes. This is because noon begins at 11am, and due to the fact that I do not need any changes until it starts to get dark (at 7pm) so I have set up an 8 minute timer (to signify the 8 hours between 11am and 7pm) This is done right at the beginning of your sequence so that time never really stops, even if you've set up a sequence of events to signify the changing of the day. In my case, mostly for the sake of testing I've set up a simple text command to tell the player that 'It's Noon.' Once this has passed, the event is no longer useful as it has achieved its function so the switch governing it is turned off. The switch that turns on the sequence of checkers and changers for the next time of day (dusk) is then turned off.
Step 4:
Repeat this sequence of events for each phase in your day until you're back at the sequence you started at. You don't need to change the events that I've suggested for any of them except the timers (which need to correspond to the duration between the phase that you are entering and the next phase in the sequence if you know what I mean.Step 5:
On the very first map of your game, where it actually becomes playable, you need to set up an event to initialise your time system. As you can see, the event needs to turn on the switch 'Time Start', initialising your Time Start common event and then erase itself. This is so that time does not restart itself at your chosen start point every time you enter that map. You may also find that in some cases, not erasing the event can cause a loop that freezes your game as it is concentrating on processing the same event, over and over and over and over and over.Step 6:
Playing around with your system, tweaking it to make it perfect and adding to it can be really rewarding so go a little crazy with it. Some of the potential things I have managed to implement (but won't put on here unless you ask for it)- Stores that open and close in the morning and evening
- Certain events and monsters that only come out at night
- A complete change of scenery when night descends
- Different character behaviours during the evening and even the appearance of new characters in the evening
I'm still working on this but to be honest I'm more optimistic about my other system which, although being longer is actually simple and offers far more versatility as it creates a 24 hour day, not a day broken up into 5 or so sections.
Note: Why I don't use rolling seasons: The change of seasons is classically used to symbolise the passing of a long amount of time. If you intend to show a significant passage of time (a few months) then changing the seasons is the best way to do it...thus adding it to a rolling system would not be a good idea. Also, to get realistic seasons in place, you're going to need a long period of gameplay...literally hours. That would work if you're setting up an MMORPG or Sandbox game but not if you're just putting together a simple project.
No comments:
Post a Comment