Need some help creating a dialogue script

So I’m struggling with trying to make a dialogue script for what I’m working on, mainly since I’m not fully familiar with C#. The main goals of the dialogue script is that it take a string via a function and displays it until either it completely fills the dialouge box, or it reaches the end of the string. I also need to make that it display the image and name of the person talking, as well as allowing someone to put in the dialouge and set the text speed.

Show what you’ve got so far. I doubt anybody is going to write this script for you. It’s much better for people to help you with what you’ve done then.

Sure, but I don’t have much and just need some pointers at least.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
public TextAsset textFile;

// Start is called before the first frame update
void Start()
{
if(textFile != null);

}

// Update is called once per frame
void Update()
{

}
}

Correction. There is nothing above. No offense, but start with some tutorials. There are hundreds of thousands of them. It’s not EVER going to just be a script. NOTHING is ever just a script, trust me.

7293334--882550--Screen Shot 2021-07-02 at 11.00.34 AM.jpg

1 Like

I’ll trust you on that, and apologizes for presenting absolutely nothing to work with.

I’m going to disagree just a little. You at least made a script. :smile: I’ll question the name of your class since that is just the default name, but you know. It’s still a base to build on. Next, you need to break down what you want to do.

  1. take a string via a function
  2. displays it until either it completely fills the dialouge box
  3. or it reaches the end of the string
  4. make that it display the image (person talking)
  5. and name (person talking)
  6. allowing someone to put in the dialouge and set the text speed

There, I dissected your paragraph. It now looks less challenging to take each step one at a time. Follow any good tutorial and they will do the same usually when it comes to beginners. Remember, saying you want to build a car is easier when you actually build the parts first.

But yes, tutorials will be a big help to start you off as well.

1 Like

Thank you for breaking it down for me, it does help me to try and tackle it one by one. Still completely stumped by this, and if it important, I’m trying to make a dialogue script for Universal Render Pipeline

Can someone at least tell me how to take in string and print it out, because I have absolutely no idea what I’m trying to do.

Don’t conflate the function of the dialog system (eg, the states that it can be in, what it is showing the player, what the player selects) with the presentation (text, graphics, whatever) to the player.

They are two completely different things, completely and totally disconnected from each other.

If you like, make the dialog system first so that it works entirely with Debug.Log() output, and once you have the dialog tree choice following mechanism 100% nailed down (AND YOU CAN EXPLAIN IT TO YOUR DOG!), then see if you can present it with fancy schmancy graphics and text. Never try to do the whole thing at once.

ALSO, with that in mind, try a few of the tutorials I linked above. It will always give you insight to see how other people do stuff.

How to do tutorials properly:

Tutorials are a GREAT idea. Tutorials should be used this way:

Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation generally ends in disaster. That’s how software engineering works. Every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly. Fortunately this is the easiest part to get right. Be a robot. Don’t make any mistakes. BE PERFECT IN EVERYTHING YOU DO HERE.

Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost.

Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.

Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

Okay, you need to put the dialog project aside seriously because you’re just spinning wheels if you can’t output a string. Start here, and see my note above about tutorials:

Imphenzia / imphenzia - super-basic Unity tutorial:

https://www.youtube.com/watch?v=pwZpJzpE2lQ

Jason Weimann:

https://www.youtube.com/watch?v=OR0e-1UBEOU

Brackeys super-basic Unity Tutorial series:

https://www.youtube.com/watch?v=IlKaB1etrik

Sebastian Lague Intro to Game Development with Unity and C#:

https://www.youtube.com/watch?v=_cCGBMmMOFw

Imphenzia: How Did I Learn To Make Games:

https://www.youtube.com/watch?v=b3DOnigmLBY

Sorry for being a idiot.

As long as you are learning you are not an idiot. Keep iterating and taking steps that are reasonable for your current state of being. Dialog systems are abstract and complicated beasts. Work within your comfort zone to build up confidence and then build upon good foundations to move onto the next thing, and the next thing.

Learning is not an event, like a sneeze, and then it’s over with.

It’s a process: daily preparation and iteration and steadily building upon previous learnings.

2 Likes