How To: Skip To Player's Line

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

How To: Skip To Player's Line

Post by Tony Li »

To skip all NPC lines until the conversation reaches a player line, use a script like this:

NPCLineSkipper.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class NPCLineSkipper : MonoBehaviour
{
    public bool skipToPlayerLine = false; //<-- SET TRUE TO SKIP NPC LINES.
    
    void OnConversationLine(Subtitle subtitle)
    {
        // If speaker is NPC and the next line is also an NPC line, skip ahead by setting the Sequence to Continue():
        if (skipToPlayerLine && subtitle.speakerInfo.isNPC && DialogueManager.currentConversationState.pcResponses.Length == 0)
        {
            subtitle.sequence = "Continue()";
        }
    }
}
Post Reply