Making a day/night system

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Making a day/night system

Post by lostmushroom »

Hey everyone

I'm wondering if it's possible to make a day/night system using Dialogue System. There's a few things I'd like to do, for example:

- Some quests only available at certain times of day
- Some areas off limits at certain times of day, such as a shop being closed at night
- Characters being in different places at different times of day
- You have to wait a certain amount of days before something happens

So far, I figured I could have variables for 'morning, 'afternoon', 'evening' and so on, having them switch on and off throughout the 'day'. But is there a way to have them switch on and off on a timer? Or would that require some custom code.

Alternatively, is there a way to make these variables somehow interact with the timeline object that is controlling the visual side of the day/night cycle?

If anyone has done something like this before, any advice is much appreciated :) Thanks!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Making a day/night system

Post by Tony Li »

Hi,

It's possible. Set up some variables -- either 'morning', 'afternoon' and 'evening'; or an 'hour' variable that cycles through 0 - 24 throughout the day. If you maintain this variable in a script, I recently posted ways to sync your script variable with the Dialogue System. The third (a Lua function) would be best in this case.

> - Some quests only available at certain times of day

Add 2 branches to your conversation. For example:
  • Branch 1: (Conditions: hour > 17) "Want to steal a car for me tonight?"
  • Branch 2: (Conditions: hour <= 17) "Sorry, come back at night."

> - Some areas off limits at certain times of day, such as a shop being closed at night

If they use Scene Portals or Dialogue System Triggers to access the area, you can set up the Condition to check the variable(s).


> - Characters being in different places at different times of day

If the characters will move around in the scene, this is probably best handled at your script level. However, if you're only concerned about setting them up in the correct location when the scene starts, Dialogue System Triggers will work fine. For example, let's say the Baker works in the Bakery from midnight to 10 am, and is at home from 11 am to midnight. Set up 2 Dialogue System Triggers.
  • In the Condition of one, require that (hour <= 10), and use select Add Action > Play Sequence. Move the MoveTo() sequencer command to move the Baker to the Bakery.
  • In the Condition of the other, require that (hour > 10), and use select Add Action > Play Sequence. Move the MoveTo() sequencer command to move the Baker to home.
> - You have to wait a certain amount of days before something happens

You can keep track of this in a variable.


> So far, I figured I could have variables for 'morning, 'afternoon', 'evening' and so on, having them switch on and off throughout the 'day'. But is there a way to have them switch on and off on a timer? Or would that require some custom code.

You could jerry rig something in the Dialogue System, but it's probably best to write some custom code or use something like UniStorm (the Dialogue System has integration) that runs the timer.


> Alternatively, is there a way to make these variables somehow interact with the timeline object that is controlling the visual side of the day/night cycle?

Use can use the 'Play Sequence' Timeline action to set a variable at certain points in the timeline.
lostmushroom
Posts: 194
Joined: Mon Jul 01, 2019 1:21 pm

Re: Making a day/night system

Post by lostmushroom »

Amazing, thanks so much! I'll give this a try. Should be fun :D
Post Reply