Page 1 of 1

How To: Skip To Player's Line

Posted: Wed Dec 18, 2019 9:46 am
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()";
        }
    }
}