Forum rules - please read before posting.

Speech event token is triggered immediately

edited March 2022 in Technical Q&A

Hi,

assuming I have this speech text

A character is speaking and then the character [gesture:pointing] refers to something in front of the character.

I would expect the character to play a hand pointing animation about half way through the speech line. Instead, it's played the moment the speech line begins.

The audio file is not synced with the text so there's no way for the engine to know the specific time of that token's position, however setting the delay based on the "Display time factor" property in the Speech manager would be sufficient enough. If such thing is possible, how do I achieve it?

Considering other alternatives to get that behaviour such as splitting the speech line into multiple speech lines or playing the animation from within a parallel thread, I would prefer using speech event tokens.

How do you use speech event tokens? Anyone encountered this problem?
Thanks.

AC 1.75.0

Comments

  • I'd personally make use of Timeline when it comes to syncing animations with speech, but admittedly that'd be more involved an alternative than the ones you've suggestd.

    If speech-scrolling is disabled, then tokens are processed in the first frame of the speech's lifetime.

    It does, however, account for wait tokens - an alternative that avoids creating a separate speech line would be to instead use the text:

    A character is speaking and then the character[wait:1] [gesture:pointing] refers to something in front of the character.

    If you checked Treat carriage returns as separate speech lines? in the Speech Manager, you could also use the following text in a single speech Action:

    A character is speaking and then the character
    [gesture:pointing] refers to something in front of the character.

  • Thanks for the details, Chris. I tried your suggestions and this is my result.

    Speech-scrolling and wait tokens breaks skipping behaviour, it requires to then click twice.
    Timeline prevents speeches from being skipped.
    Splitting lines by carriage returns breaks the audio playback.
    My suggested alternative with playing the animation from a parallel thread delayed with the "Engine: wait" action won't work either as it causes the game to get "stuck" for a while outside of a gameplay state in the event of the speeches being skipped.

    If anyone is dealing with a similar issue this is the solution I'm going with. The goal is to play a specific gesture for a specific speech with a specific delay and having the ability to skip the speech including the gesture animation.

    I created a custom AC action which takes AssociatedSpeechID, Clip, MecanimLayer, Delay as variables.

    This action starts a coroutine, the coroutine waits for the delay time and then checks whether the associated speech is still active and if that's true the animation is being played.

    On speech skip if the gesture animation is playing it's skipped too. That's controlled by animator transitions.

    https://pastebin.com/dhzHh2TU

  • Timeline prevents speeches from being skipped.

    A script on the AC wiki provides this: https://adventure-creator.fandom.com/wiki/Skipping_Timeline_speech

    I created a custom AC action which takes AssociatedSpeechID, Clip, MecanimLayer, Delay as variables.

    If you're considering entering in a Delay value as a property of the gesture, you could embed this into the speech token itself, i.e.:

    [gesture:pointing_0.3]
    

    And then extract this time value from the token value parameter:

    private float GetDelay (string tokenValue)
    {
        int timeIndex = tokenValue.IndexOf ("_"[0]);
        if (timeIndex > 0)
        {
            string timeValue = tokenValue.Substring (timeIndex);
            float delay = 0f;
            if (float.TryParse (timeValue, out delay))
            {
                return delay;
            }
        }
        return 0f;
    }
    
  • Timeline is a viable option then. Great.

    If you're considering entering in a Delay value as a property of the gesture, you could embed this into the speech token itself.

    Good point, this way the coroutine could be started from the event and thus there would be no need for the custom action.

    Even though I have to yet decide what approach to choose, I have all the information I need.
    Thanks!

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.