Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The name reminds Gary Wright song Dream Weaver.

Serious question though: how do you get the dialogue to do that thing where it slowly appears, but then fully appears if you press the space bar? Is it an animation on the text element? is it a function in the text? I would love to know!

Apologies for the very late reply!

The system is composed of "DialogueManager.cs" (handles typewriter effect, advancing lines, freezing player) and "DialogueData.cs" (ScriptableObject to store lines + portrait per conversation).

So it is done entirely in code, no animation needed. I believe it is called "typewriter effect". I use IEnumerator:

private IEnumerator TypeLine(DialogueData.DialogueLine line)
{
    isTyping = true;
    dialogueText.text = "";
    foreach (char c in line.text)
    {
        dialogueText.text += c; // this will add one character at a time
        yield return new WaitForSeconds(typeSpeed); // this will wait between each character
    }
    isTyping = false;
}

It loops through every character in the string one by one, adds it to the text, then waits a tiny amount of time before the next one..

The press space to complete instantly part is just:

if (Input.GetKeyDown(advanceKey))
{
    if (isTyping)
        SkipTypewriter();
}
private void SkipTypewriter()
{
    StopCoroutine(typeCoroutine);
    dialogueText.text = currentDialogue.lines[currentLineIndex].text; // this will show the line all at once
    isTyping = false;
}

Let me know if this helps :)