Zelda-like conversations
Hello! I am currently in the process of making a game and I am thinking of a way to do conversations that appear, letter by letter (kind of like in Zelda or similar games). I do not have the money to buy an asset from the store, so I wonder if anyone knows how to make a conversation like this?
Answer by etopsirhc · Sep 23, 2015 at 10:17 PM
not tested, but this is more or less what you are looking for.
string fullText = "your zelda like text here";
string displayText = "";
float typeDelay = 0.3f; // just an estimate
int nextCharacter = 1;
Update(){
if (nextCharacter <= fullText.length){
displayText = fullText.subString(0,nextCharacter);
YourTextBox.text = displayText;
nextCharacter++;
}
}
There seems to be a lot of parts missing to this, was this meant for a script with texts that are done? Also, where does typeDelay come in? I think this is well on the way to working though.
yeah, >< guess i shouldn't answer questions at 4am too tired to remember to make things work. the "YourTextBox" would be a variable linked externally to the GUI textbox meant to display the text. this it meant to be a bare bones setup, enough for the concept to work, but would need some things changed to actually incorporate it in a useful way.
string fullText = "your zelda like text here";
string displayText = "";
float typeDelay = 0.3f; // just an estimate
float lastCharacterTime= 0f;
int nextCharacter = 1;
Update(){
if (nextCharacter <= fullText.length){
if (typeDelay <= lastCharacterTime){
displayText = fullText.subString(0,nextCharacter);
YourTextBox.text = displayText;
nextCharacter++;
lastCharacterTime = 0;
}else{
lastCharacterTime += Time.deltaTime;
}
}
}
Right, I think we're nearly there, the YourTextBox.text section doesn't like the .text part, and I end up adding a static string (or something like that) to make it happy, I am a bit rusty with Unity, so forgive me for my lack of knowledge, I really appreciate your help.
Side note: Although @etopsirhc had the original code, @bubzy was the one who solved it in the end! $$anonymous$$udos to both of you though!
Answer by C4TFLY · Sep 28, 2015 at 06:58 PM
Once again, I feel very stupid and I feel like I am missing something completely obvious, but here goes;
I have included a screenshot of the hierarchy and the text inspector, I will also include the slightly edited code, nothing that should matter.
wich ever object in the scene has the script attached to it, you need to select that, then drag the text box into the open slot labeled TestText.
YES! After a proper read of the errors and doing what you told me, it finally worked!
https://gyazo.com/02430074ab2a96d86143dd42b108cdea
I really appreciate all your help! I am forever in your favor!
Your answer
![](https://koobas.hobune.stream/wayback/20220612034814im_/https://answers.unity.com/themes/thub/images/avi.jpg)