Forum rules - please read before posting.

Stop Speech Question

Hey!

I have a scenario in-game in which an action list is playing in the background which triggers play speech
https://i.imgur.com/hWblpWo.png
Carriages are set up as separate lines, so it this spits out multiple lines of dialogue.

While this is playing in the background, the player is able to speak to a different NPC if they want.

I currently have Kill speech set up before the new NPC talks, but it only kills one line of the original NPC's speech, and just continues the next causing the conflict.

I can get around it by killing that action list + Kill all speech before the new NPC talks.

However there are quite a few other scenarios in which the player can trigger a speech to play in the background with multiple lines, and then talk to a NPC.

I figure I can set up a universal action list that kills all action lists with speech that could conflict and then put it on each object. However I'm not sure if this is the smartest solution? Is there something I'm missing? Am I using Stop All Speech correctly?

Comments

  • Separating lines in a single speech Action with carriage returns is equivalent to separating them with individual Actions - so killing one speech line won't affect the next.

    Better to use some simple code for something like this. One way you could do it is listen out for a new speech line beginning. If speech is played during a cutscene, kill the background speech and your unwanted ActionLists:

    using UnityEngine;
    using AC;
    
    public class EndBackgroundSpeech : MonoBehaviour
    {
    
        [SerializeField] private ActionList[] actionListsToKill;
        [SerializeField] private AC.Char characterToStopSpeaking;
    
        private void OnEnable () { EventManager.OnStartSpeech += StartSpeech; }
    
        private void OnDisable () { EventManager.OnStartSpeech -= StartSpeech; }
    
        private void StartSpeech (AC.Char character, string lineText, int lineID)
        {
            if (KickStarter.stateHandler.IsInCutscene ())
            {
                foreach (ActionList actionListToKill in actionListsToKill)
                {
                    actionListToKill.Kill ();
                    KickStarter.dialog.EndSpeechByCharacter (characterToStopSpeaking);
                }
            }
        }
    
    }
    

    This script requires to explicitly define the ActionLists you want to end when cutscene speech begins, but you could adapt it to automatically kill ActionLists with a certain tag if you wanted.

  • This is great thank you, I need to delve deeper into this!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!