Forum rules - please read before posting.

combining shape keys and texture changes in expressions

Hi, I was wondering if doing expressions with changing eyes and brows with shape keys and changing textures could be easily combined. Has anyone used such an approach?

Comments

  • Well, I should have known it was already implemented...

  • Does the expression token only change the dialog portrait texture? I was hoping to change the texture of the game object as well. And for some reason after speech the first phoneme texture remains the face texture of the game object. What am I doing wrong?

  • edited December 2020

    If your Speech Manager's Perform lipsync on field is set to Game Object Texture, then character's can change their texture to match the phoneme. You'll need to add and configure a "Lip Sync Texture" component on the character as an extra step, though.

  • Phonemes seem to work ok, but not the expression textures. Basically the first phoneme replaces the neutral expression.

  • The first phoneme should be treated as the "rest" pose.

    Are the textures applied when speaking? Share screenshots and version numbers if you need specific advice.

  • Phoneme textures are applied when speaking, but the expression textures are not used.

  • Shape keys work with the expression tokens perfectly as well.

  • Here's a picture of the problem: Image

    First one shows smiling shape key, but without texture.
    In the second one the expression token is not changed, but the shape key is lost - phoneme textures seem to work ok.
    The last one has correct texture and shape key.

  • AC is 1.72.4, Unity 2020.1.8f1

  • Since the expressions don't have any mesh or material target, should I understand that it only applies to this menu texture and I should swap the texture of the player/npc by some other script?

  • should I understand that it only applies to this menu texture and I should swap the texture of the player/npc by some other script?

    Yes, that's right. You'll get a conflict with phoneme texures, though, if your textures are being applied to the same material.

    What you'd need to do is modify the LipSyncTexture component so that the list of textures change with each expression. So you have a set of "normal" phoneme textures, "happy" phoneme textures, etc.

    If all phonemes except for the first (i.e. rest) remain the same for each expression, you could likely get by just updating that externally, i.e.:

    using UnityEngine;
    using AC;
    
    public class ExpressionLipSync : MonoBehaviour
    {
    
        private Char character;
        private LipSyncTexture lipSyncTexture;
        private int lastExpressionID = -1;
    
        void Awake ()
        {
            character = GetComponent <Char>();
            lipSyncTexture = GetComponent <LipSyncTexture>();
        }
    
        void Update ()
        {
            int expressionID = character.GetExpressionID ();
            if (lastExpressionID != expressionID)
            {
                lastExpressionID = expressionID;
                Texture2D newTexture = GetExpressionTexture (expressionID);
                lipSyncTexture.textures[0] = newTexture;
            }
        }
    
        Texture2D GetExpressionTexture (int ID)
        {
            foreach (Expression expression in character.expressions)
            {
                if (expression.ID == ID)
                {
                    return expression.portraitIcon.texture;
                }
            }
            return null;
        }
    
    }
    

    Try attaching that to the character (with the LipSyncTexture component also on the root).

  • Thanks. It works quite nice - there was a cast missing in GetExpressionTexture, but the texture change has an irritating lag. I was thinking of doing a lateUpdater that would have swapped the texture if IsTalking was false, but this is less intrusive.

  • Switching to lateUpdate for the lipSync fixed the lag.

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.