Forum rules - please read before posting.

Lip-sync and Sprite Unity Complex

edited March 2020 in Technical Q&A

Hello! I decided to write here after a deep research on forum that gave me no results.
I'm trying to get lip-sync (from speech text) with a Unity Complex Sprite. I created "Phoneme" integer parameter in the animator, and i see it takes phoneme number in runtime. The issue is that i can't "link" that parameter to the frame into the animation. (I already set phonemes in AC Game Editor).

What am I doing Wrong? Thanks in advance

Comments

  • Welcome to the community, @MidMagic.

    AFAIK, Unity's Animator system unfortunately doesn't make it too viable to actually play a specific "frame" of an animation - it's best to stick to Unity's best practices regarding animation playback.

    By this, I mean each phoneme would be a separate animation clip - and then you can switch between each clip using a Blend Tree mapped to the Phoneme integer.

    Otherwise, you'd have to look into some custom scripting to basically force-set a specific sprite in LateUpdate - overriding the effects of the animator. Something like:

    public AC.Char myCharacter;
    public SpriteRenderer spriteRenderer;
    public Sprite[] mouthSprites; // Assign as many sprites as you have phonemes
    
    void LateUpdate ()
    {
        int currentFrame = myCharacter.GetLipSyncFrame ();
        if (currentFrame > 0)
        {
            spriteRenderer.sprite = mouthSprites[currentFrame - 1];
        }
    }
    
  • Thank you so much Chris!

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.