Force a decision with a timer#
A timed choice gives the player a few seconds to decide before the conversation decides for them. You'll stage a wolf attack at the gate, give the player five seconds to react, and write what happens if they freeze.
Before you begin#
Complete Give the player a choice. This guide uses a new Script, so create one named Wolf Attack and assign it to the guard's Dialogue component in place of Gate Conversation.
Put the choices on a clock#
Metadata at the end of a choice changes how its group behaves. Write the attack and add the timer to the first choice:
A wolf leaps out of the dark, straight at the guard!
Guard: Behind you! Do something!
* Draw your sword and charge. [timed: 1, duration: 5]
You slash at the wolf, and it flees into the trees.
* Throw your torch at it.
The wolf yelps and bolts from the flames.
* Run for the gate.
You slip through the gate while the guard fights alone.timed: 1 turns the timer on, and duration: 5 gives the player five seconds. Although the metadata sits on one choice, it applies to the whole group. When choices in the same group set the same key differently, the highest value wins.
The sample Skin shows a bar that empties as the time runs out. duration also accepts decimals, so [duration: 2.5] gives the player two and a half seconds.
Choose what happens at zero#
By default, Dialogue picks one of the available choices at random when time runs out. The timeout key changes that:
timeout |
When time runs out |
|---|---|
0 |
Picks an available choice at random. The default. |
1 |
Picks the first available choice. |
2 |
Picks the last available choice. |
3 |
Picks nothing and continues after the group. |
A random pick suits a reflex, where any reaction is plausible. For this scene, freezing in fear is more interesting, so use 3:
* Draw your sword and charge. [timed: 1, duration: 5, timeout: 3]Write what happens if they freeze#
With timeout: 3, the conversation skips every branch and continues with the first line after the group. Put the hesitation there, and send the answered branches past it with a Label:
A wolf leaps out of the dark, straight at the guard!
Guard: Behind you! Do something!
* Draw your sword and charge. [timed: 1, duration: 5, timeout: 3]
You slash at the wolf, and it flees into the trees.
@go after-attack
* Throw your torch at it.
The wolf yelps and bolts from the flames.
@go after-attack
* Run for the gate.
You slip through the gate while the guard fights alone.
@go after-attack
You freeze. The guard shoves you aside and drives the wolf off himself.
Guard.angry: Stand there like that again, and I'll let it eat you.
# after-attack
Guard: That's the fourth one this week.Lines after a group normally run after every branch. Here each branch jumps to after-attack, so only a player who let the clock run out sees the guard's scolding. Everyone hears his last line.
Build tension before the choice#
A pause before the choices gives the moment more weight. @wait holds the conversation for a number of seconds, and [continue: 1, timeout: 2] makes one line advance on its own after two seconds:
Something moves in the trees beyond the torchlight. [continue: 1, timeout: 2]
@wait 1
A wolf leaps out of the dark, straight at the guard!The first line now leaves the screen by itself, then nothing happens for one second before the wolf appears. Like duration, both a line's timeout and @wait accept decimals, such as 1.5.
Timers follow game time
By default, the choice timer and line timeouts stop while Time.timeScale is 0, which is how most games pause, so opening a pause menu doesn't cost the player their decision. Add unscaled: 1 to a group or line only when its timer must keep counting while the game is paused.
Verify the result#
Enter Play mode and walk up to the guard three times:
- Pick Throw your torch at it. before the bar empties. The wolf flees, and the guard says That's the fourth one this week.
- Let the bar empty. You freeze, the guard scolds you with his angry portrait, then says his last line.
- Watch the opening: the first line disappears on its own, and the wolf appears a second later.
Where to go next#
- Run game actions from a conversation — make the wolf attack change the game, not only the text.
- Scripts — every metadata key a choice group accepts.
- Language syntax —
@waitand itsunscaledoption.