Greet the player differently on each visit#
An NPC who repeats the same introduction every time feels like a sign, not a character. You'll give the guard a varied remark, a greeting that warms up over several visits, and an introduction that plays only the first time, then keep that memory in the save file.
Before you begin#
Complete Lock dialogue behind a requirement, which introduced Conditions. This guide rewrites the Gate Conversation Script; assign it back to the guard's Dialogue component.
Vary a remark#
@select plays one of the lines indented under it, then continues after the block. Replace the text of Gate Conversation with:
Guard: Evening.
@select random-no-repeat
Guard: Quiet night, so far.
Guard: Mind the mud by the well.
Guard: Heard wolves again before dawn.Each indented line is an option. Every time the conversation reaches the block, the guard says one remark, and random-no-repeat never picks the same one twice in a row. The word after @select is its mode, and Language syntax lists them all.
Warm up over several visits#
A greeting that changes as the guard gets to know the player needs an order, not chance. Replace Evening. with a sequence-hold block:
@select sequence-hold [id: guard-greeting]
Guard: Halt. State your business.
Guard: You again. Keep out of trouble.
Guard: Good to see a friendly face.
@select random-no-repeat
Guard: Quiet night, so far.
Guard: Mind the mud by the well.
Guard: Heard wolves again before dawn.sequence-hold plays its options from top to bottom, one per visit, and keeps repeating the last one once it gets there. The first visit plays Halt., the second You again., and every visit after that Good to see a friendly face.
The progress belongs to the guard's Dialogue component, so another NPC that uses the same Script keeps its own count. The id lets the save system store that progress, which you'll set up at the end of this guide.
Introduce the guard once#
A first meeting is usually more than one line, with its own back-and-forth. Dialogue remembers every line with an id that a Dialogue component has played, so a Condition can ask whether the introduction has happened.
First, give the opening line of the introduction a readable identifier. Each id must be unique within its Script:
Guard: Halt! I haven't seen you around here before. [id: guard-intro]Next, open the Village Compendium and add a Condition named met-guard with one check:
| Condition | Configuration |
|---|---|
| Has Visited Script Line | Dialogue set to Source, Line ID set to guard-intro. |
Inside a Script, Source is the game object of the Dialogue component that's running it, so this check reads the guard's own memory. The default Dialogue field expects a component from the scene, which a Compendium asset can't hold.
Finally, route the conversation with @if met-guard:
@if met-guard
@select sequence-hold [id: guard-greeting]
Guard: You again. Keep out of trouble.
Guard: Good to see a friendly face.
@else
Guard: Halt! I haven't seen you around here before. [id: guard-intro]
Player: The name's Ash. I just arrived.
Guard: Bram. Keep your nose clean, and we'll get along fine.
@select random-no-repeat
Guard: Quiet night, so far.
Guard: Mind the mud by the well.
Guard: Heard wolves again before dawn.On the first visit, met-guard is false, so the introduction plays and records guard-intro. From then on, met-guard is true, and the guard moves on to the greetings. The random remark plays after either branch.
Memory belongs to the component
Each Dialogue component keeps its own record of visited lines. That suits facts about one relationship, such as whether the player has met this guard. For facts the whole world should know, such as the player having saved the village, set a value in a Global Variable with a Command instead.
Keep the memory after loading#
So far, the guard forgets everything when the game restarts. Add the memory to the save system:
- Select the guard and add a Remember component with
Add Component→Visual Script→Remember. - Remove the default Memories you don't need, such as Transform.
- Add a Dialogue Memory.
- Set the ID to a stable, readable value, such as
guard-east-gate.
The Dialogue Memory saves every visited line ID and the progress of every @select that has an id. A @select without one, such as the random remark, starts fresh after loading.
Every line with an ID adds to the save file
The Memory stores the ID of every line the guard has played, not only guard-intro. If you ran Generate IDs on a long Script, that can be a lot of entries. Add the Memory to characters whose behavior depends on it, and leave it off the rest.
See The Remember component in the Visual Script manual for choosing IDs and save locations.
Verify the result#
Enter Play mode and talk to the guard four times:
- The first visit plays the introduction, then a remark.
- The second visit plays You again. Keep out of trouble., then a remark different from the last one.
- The third and fourth visits both play Good to see a friendly face.
Then save with your game's save Event, restart Play mode, and load that save. The guard should skip the introduction and greet the player as a friend.
Where to go next#
- Build a merchant conversation — combine Variables, Conditions, and Commands into a shop.
- Language syntax — every
@selectmode, weights, and what happens when no option is left. - Dialogue component — what the Dialogue Memory saves.