So I need a very basic dialogue system. And I don’t exactly know where to start. I would try to just make something up from scratch, but I find the whole dealing with strings and indexes, very confusing. Mostly because it’s often a pile of single letters and operators, rather than words.
I’ve seen a bunch of tutorials, and people asking this type of question, but I don’t know which ones are the most up-to-date and stuff. I don’t like following full tutorials for this sort of stuff, because one, if you don’t exactly know what’s happening, you can’t alter it very easily, especially if the tutorial starts getting into complex functionality that relies on other parts of the code. And two, you’d most likely need to find a way of contacting the guy doing the tutorial, to ask for permission to use it in a game, and sometimes that can be quite hard.
What I need from the system is:
- A box that can hold 3 lines of text
- The text appearing 1 letter at a time, known as the “typewriter effect”.
- The box emptying if it becomes full, or a new sentence starts.
- The text should not scroll in any way.
- The text should start at the top line, once it’s filled, go onto the second, and then the third.
There are other things, but these five are the main ones, and the ones I won’t be able to figure out on my own.
Anyone have any suggestions?
Also, if you have any code you’d like to share, that would help too.
P.S. I know the UI side of it, so don’t worry about explaining it, or linking stuff that talks only about the UI.
Brackey’s has something close to your description.
1 Like
This isn’t directly related to the dialogue system (imo), but what would be a good way of organizing the triggers?
In the tutorial, he triggers it with a button press. But what if my game has a great deal of different objects that you can inspect, by pressing a key?
Certainly making a single script, calling the “TriggerDialogue()” function, for every item would pretty much be madness. So what should I do?
For example, let’s say there’s 10 items in a room (book, old chair, grandfather clock, etc.), and I want a dialogue box to pop up, saying a different thing for every single object. How would I organize that?
That is a challenge that comes with making a game that has many interactive objects.
I’d put a script on each item that’s interactive with its text on it, and call the TriggerDialogue(OtherObject.GetComponent().DialogueText) function. The DialogueText string in the InteractiveElement script on the objects would provide the text in the box.
Also, you could have 1 script with a long dictionary, perhaps a <GameObject, String> KeyValuePair, then go thru the dictionary to find the text you want.
It might seem ugly, but at 1 point or another you will have many strings of text somewhere.
1 Like
Yeah, I would do it that way also, but I would put a collider around the object and make it a trigger so when you got close, it would automatically pop up. You could just make one and then make it a prefab and keep a list or whatever with the text on the prefab. Then you would just drop it on the item and change the text for that specific item.
2 Likes
Thanks guys, I’m all set now. 