Skip Typewriter Effect for Player

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Skip Typewriter Effect for Player

Post by ar4wy »

Hi Pixel Crushers!

Right now, I have Dialogue Manager set up to show both the NPC and PLAYER dialogue.

When the player chooses a response, it types out the response after being clicked. (Some players find this redundant, and just want their chosen line to instantly appear.) How would I do this?

I know I could prepend/append all my player lines with the typewriter markup />something/< , but I'm sure there is a better way to skip the typewriter effect for player dialogue!
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip Typewriter Effect for Player

Post by Tony Li »

Hi,

Here are two suggestions:

1. Assuming the player uses a different subtitle panel than NPCs, remove the typewriter effect from the player's subtitle panel. For example, the Basic Standard Dialogue UI has an NPC Subtitle Panel and a PC Subtitle Panel. Inspect the PC Subtitle Panel's Subtitle Text and remove the UnityUITypewriterEffect component.

2. Inspect the Dialogue Manager. Tick Subtitle Settings > Skip PC Subtitle After Response Menu.
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Skip Typewriter Effect for Player

Post by ar4wy »

Hi Tony!

The player and the NPC share the same subtitle panel. I believe what I have is based on WRPG template.

If I skip the PC subtitle, there is no record of what the player has said.

Is there a script that modifies only player lines of dialogue? Or the "responses"? (So that I do not have to manually enter \>line\< for each player line of dialogue?

Thanks!
Remy
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip Typewriter Effect for Player

Post by Tony Li »

Hi Remy,

You can add a script like this to the Dialogue Manager:

SkipTypewriterForPlayer.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class SkipTypewriterForPlayer : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.isPlayer)
        {
            subtitle.formattedText.text = @"\^" + subtitle.formattedText.text;
        }
    }
}
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Skip Typewriter Effect for Player

Post by ar4wy »

Hi Tony,

This works great!

I have the character names turned on, so the name always appears before the dialogue.

///

Example:

PLAYER: Hello, how are you?

NPC: I am fine.

///

Right now, the dialogue text appears instantly, but the Player name still gets typed out. Is there a way to also include the player name in this instant text script?

Thanks!
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip Typewriter Effect for Player

Post by Tony Li »

Hi,

The character name gets added to the front of the text after OnConversationLine() runs, as you've seen.

Try changing the script to this instead, which will enable and disable the typewriter effect instead of injecting a code to fast-forward it:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class SkipTypewriterForPlayer : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        var dialogueUI = DialogueManager.dialogueUI as StandardDialogueUI;
        if (subtitle.speakerInfo.isPlayer)
        {
            dialogueUI.conversationUIElements.defaultPCSubtitlePanel.GetTypewriter().enabled = false;
        }
        else
        {
            dialogueUI.conversationUIElements.defaultNPCSubtitlePanel.GetTypewriter().enabled = true;
        }
    }
}
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Skip Typewriter Effect for Player

Post by ar4wy »

Hi Tony,

I have a bit of a different problem now.

I want to NPC's name to be instant, but I want what the NPC says to be typewriter.

When I do this by using:

Code: Select all

void OnConversationLine(Subtitle subtitle)
	{
		subtitle.speakerInfo.Name = "\\>" + subtitle.speakerInfo.Name + "\\<";
	}	
The responsemenu lags quite a bit before showing up. I think it has to do with what you said about this happening AFTER OnConversationLine?

Do you have any advice how to make the NPC's name be instant without this lag?

Thanks!
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip Typewriter Effect for Player

Post by Tony Li »

Hi,

Presumably it's lagging because the node's Sequence -- or the Dialogue Manager's Default Sequence if the node's Sequence is blank -- is set to something like:

Code: Select all

Delay({{end}})
The value of {{end}} is based on the length of the text, including the name. It doesn't take RPG Maker codes into account.

Try changing the sequence to:

Code: Select all

Continue()@Message(Typed)
This will make the node continue the conversation (i.e., to the response menu) as soon as the typewriter has finished typing.
ProjectN
Posts: 1
Joined: Wed Feb 01, 2023 6:24 am

Re: Skip Typewriter Effect for Player

Post by ProjectN »

Code: Select all

Continue()@Message(Typed)
This makes subtitle not showing. I checked the document of "Continue" and it's designed.
Is there any way to delay smartly according to typewriter, but still shows subtitle as usual?
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: Skip Typewriter Effect for Player

Post by Tony Li »

Hi,

Are there any errors or warnings in the Console window when this happens?
Post Reply