Quick Dialogue Example

Using this forum to answer a question with illustrations from Udemy, as it’s image box is currently broken.

Are you looking to show a completely different dialogue scriptable object? We haven’t really covered that, as the current structure is designed to work with exactly one Dialogue.

What we can do, however, is to ensure that our first nodes are selected correctly based on having the quest or not…

For an example, let’s assume you have a character who gives you a boring generic greeting if you don’t have a quest, or a hint if you do have the quest but have not completed it.

Here’s a simple sketch of the two branches

What we’re looking for is for the first response to occur only if the character isn’t on the quest, and the 2nd response to occur only if it is on the quest. So when we go in to the inspector for the Nice Day for Fishing node, we’ll need a Condition that reads the equivalent of :

if(!HasQuest("SwampDonkey") || CompletedQuest("SwampDonkey")) , as we want this to fire in the event that either of these conditions are true (because if you’ve completed the quest, you still “have” the quest in your QuestList.

For this, we’re going to put in the HasQuest with a Parameter of SwampDonkey, and check the Negate. Then, we’re going to check the + button that’s directly attached to the OR box (remember that the OR box is INSIDE an AND box, so in this case, the next to the last +. That will create a new box within the OR box, where you can add the CompletedQuest with a Parameter of SwampDonkey, with the Negate unchecked.

image

Now for the other dialogue, we only want this to display if the character has the quest, and has not completed the quest.

if(HasQuest("SwampDonkey") && !CompletedQuest("SwampDonkey"))

For this, we’re going to add the 2nd condition with the +/- in the And box on the bottom of the Condition display.

It will look like this:

Each Or is in it’s own Element box. This is an And condition, and both conditions must be true to display.

Remember that for branching, you need to cover all possible conditions. In this case, there are three possible states:

  1. Does Not Have Quest

  2. Has Quest, has Not Completed

  3. Has Quest, has Completed.

Conditions 1 and 3 were covered with the first OR test

Condition 2 was covered with the And test.

Privacy & Terms