Need Help understanding how to implement a Dialogue System.

So for the past couple of days, I’ve been attempting to implement a functional dialogue system into my project where the player can select choices for some parts of dialogue. I’ve looked into tutorial after tutorial and it feels like with every tutorial I watch the more frustrated I get. I’ve taken the possibility of going down a route that includes scriptable objects. So far I know how to make a scriptable object but I’m not exactly sure how to implement scriptable objects in code. For example, if I were to make a conversation I don’t know how to make the conversation start nor how to display it onto a dialogue box for the player to see.

By the way, I’m not asking for plugins/unity store things. I’d rather learn how to do this myself and receive an explanation that can help me understand it better.

Let me give you a helpful framework to think about the problem. Let’s talk broadly about the main objects, since we have all used dialog systems.

First, there’s the individual lines. These are just strings, obviously, so putting them in a ScriptableObject is certainly reasonable.

Next there’s the notion of a given choice (node), such as:

Actor 1: “Where do you want to go?”
Actor 2: (the player) can respond:
→ “To Work”
→ “To Home”
→ “I am staying here.”

Now we need the notion of how those are combined to present a given dialog, so we’ll call that the “network” or the “tree” of choices.

Those three notions can be easily represented in static form in ScriptableObjects, linked either by some identifier, or else with references dragged into each other.

Now you need a manager that can process the network, and wait at each choice (node) for the response, then look in the network to decide where to go next based on input.

The manager can also present the current choice to the user, but it might be cleaner to just have a separate thing that presents it to the user, and also accepts input and passes it back to the manager. That way the PC version might accept input from a keyboard, but the console version would read a controller up/down and ACCEPT, for instance.

Does that help you reason about the parts you might need?

I understand the implementation of the individual lines as well as the manager to a certain degree. Although I did get a little lost on your explanation of implementing choices, by implementing them as statics what exactly do you mean by that? I know that static is a descriptor for certain variables (like public static bool for example) but I haven’t heard of any other version of it.

The term “static” I use up there is not the same context as coding. I mean “static” inasmuch as the dialog does not customize itself dynamically based on game state, such as “you get an extra option to decide you want to go to atlantis, but only if you have a submarine in your inventory.” That’s what I meant by static: an unchanging blob of predefined data (which is exactly what ScriptableObjects are good for) that plays the same regardless of dynamic game conditions.

Okay, that makes sense, so if I’m thinking about this right I’d need a scriptable object listing the name of the character speaking and the sentences. then in a separate (or in the same) scriptable object I’d have to have the dialogue options as a list?? Then after that, I’d need a dialogue manager. Am I interpreting this right?

Sounds reasonable… if that sounds like too many parts, just write it as a single MonoBEhavior with some container objects inside it for the data, write some code to dynamically create a simple dialog tree one time, and at least get the fundamental sequencing of the thing working properly FIRST. Then you can refactor the data sources and pluck them out to ScriptableObjects. That keeps it initially simple for you, all in one place. It is SOFT ware after all, which implies that it is SOFT and can be changed. :slight_smile: