Forum rules - please read before posting.

3D character animations in between dialogue?

Hello, I have an action list with a certain dialogue that is several lines long. I would like the NPC that is speaking to go through different 3D animations while the text is spoken, something like:

Lorem ipsum dolor sit amet (happy), consectetur adipiscing elit. (idle)
Quisque quis aliquet ex. (angry) Donec tincidunt id nisl vitae eleifend. (idle)
Phasellus (crying) blandit enim ullamcorper odio faucibus dapibus.

I saw on the manual that it can be done with expressions apparently, but not with animations. Is it possible by creating a custom token? I didn't really understand that part well.

Another solution for this might be to have the text's sentences in separate actionlist nodes while having then remain on screen for a similar long paragraph effect, but when I tried using [hold] it just overlapped the new dialogue on top of the previous line.
I'm very new to AC so I'm not sure if there's anything else I haven't tried. Thanks in advance~

Comments

  • Welcome to the community, @nastenka.

    Separating your speech into separate lines is possible - just check Play in background? to have an ActionList continue on without waiting for a speech line to finish - but if timing is important then it'll be tricky to get your animations to sync up this way.

    Custom speech tokens are indeed a good way to get around this. You can have a script, for example, that creates an "anim" token which invokes a Trigger parameter on the character's Animator.

    For example:

    using UnityEngine;
    
    public class CustomSpeechTokens : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            KickStarter.dialog.SpeechEventTokenKeys = new string[] { "anim" };
            EventManager.OnSpeechToken += OnSpeechToken;
        }
    
        private void OnDisable ()
        {
            EventManager.OnSpeechToken -= OnSpeechToken;
        }
    
        private void OnSpeechToken (AC.Char speakingCharacter, int lineID, string tokenKey, string tokenValue)
        {
            if (tokenKey == "anim")
            {
                speakingCharacter.GetAnimator ().SetTrigger (tokenValue);
            }
        }
    
    }
    

    This script would invoke Triggers named happy, idle, angry and crying with the altered speech text being:

    Lorem ipsum dolor sit amet [anim:happy], consectetur adipiscing elit. [anim:idle]
    Quisque quis aliquet ex. [anim:angry] Donec tincidunt id nisl vitae eleifend. [anim:idle]
    Phasellus [anim:crying] blandit enim ullamcorper odio faucibus dapibus.
    

    Personally, however, I prefer to use Unity's Timeline feature whenever timing is important. AC has its own Speech track that you can use to play dialogue, and this can be used alongisde Unity's Animation track to have animation and speech play together. The tokens method above may be more suitable for your own use-case, but for completeness, a video on using AC with Timeline can be found here.

  • Hi @ChrisIceBox , thank you!

    Separating your speech into separate lines is possible - just check Play in background? to have an ActionList continue on without waiting for a speech line to finish

    I'm not sure if I'm doing something wrong but this has the same effect as the [hold] had, the dialogue remained there but the next one just overlapped right on top. Do I have to go into Unity UI to fix that? I will have to eventually but as of now I have no idea how.

    My Unity and coding knowledge is very small and I don't really understand how I would go about implementing that code solution either (I guess I could copy and paste it somewhere but idk where or how to implement those animation triggers). On the other hand, I started watching the timeline tutorial and it does seem like the most straightforward way, so I'll see how it goes with that. Thanks a lot (⁠ᵔ⁠ᴥ⁠ᵔ⁠)

  • I'm not sure if I'm doing something wrong but this has the same effect as the [hold] had, the dialogue remained there but the next one just overlapped right on top

    Try unchecking Duplicate for each line? in the Subtitles menu's properties.

    My Unity and coding knowledge is very small and I don't really understand how I would go about implementing that code solution either (I guess I could copy and paste it somewhere but idk where or how to implement those animation triggers).

    Copy/paste the script into a C# file named CustomSpeechTokens and attach it to an empty GameObject in the scene.

    The script relies on Triggers, but that's just an example. To implement Triggers, create a Trigger parameter in your character's Animator Controller - inside the Animator window - of the same name as your token's value ("happy", "idle" etc). These Triggers will then be invoked when the dialogue reaches the tokens.

    On the other hand, I started watching the timeline tutorial and it does seem like the most straightforward way, so I'll see how it goes with that

    Yes, Timeline's a great option when you want to synchronise multiple animations and/or speech.

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.