TROUBLE with facial animation

Hello im trying to link the character animation with the facial animation(its 2d facial script that animate the uv of the facial mesh).

What i did was i put the character animation script in the main character group then put the facial animation script inside the facial mesh which is a sub group within the main character group.

using UnityEngine;
using System.Collections;

public enum Phonemes {Neutral,Aaa,Eee,Iii,Oh,Fuh,Mmm,Luh,Ess,Blink};

[System.Serializable]
public class FacialOffset
{
	//public Phonemes m_Name;
	[HideInInspector]
	public string m_Name;
	public Vector2 m_Offset;
	
	public string Name
	{
		get
		{
			return m_Name;
		}
	}
	
	public FacialOffset (Phonemes name, Vector2 offset)
	{
		m_Name = name.ToString ();
		m_Offset = offset;
	}
	
	public FacialOffset (Phonemes name)
	{
		m_Name = name.ToString ();
		m_Offset = Vector2.zero;
	}
}

public class FacialAnimationScript2 : MonoBehaviour
{
	public FacialOffset[] m_Offsets = new FacialOffset [] {
			new FacialOffset (Phonemes.Neutral),
			new FacialOffset (Phonemes.Aaa),
			new FacialOffset (Phonemes.Eee),
			new FacialOffset (Phonemes.Iii),
			new FacialOffset (Phonemes.Oh),
			new FacialOffset (Phonemes.Fuh),
			new FacialOffset (Phonemes.Mmm),
			new FacialOffset (Phonemes.Luh),
			new FacialOffset (Phonemes.Ess),
			new FacialOffset (Phonemes.Blink)
		};
		
	public void ChangeFaceToo (FacialOffset offset)
	{
		Debug.Log ("ChangeFaceToo: " + offset.Name);
		
		renderer.material.mainTextureOffset = offset.m_Offset;
	}
	
	public void ChangeFaceString (string name)
	{
		Debug.Log ("ChangeFaceString: " + name);
		
		for (int i = 0; i < m_Offsets.Length; i++)
		{
			if (m_Offsets [i].Name == name)
			{
				ChangeFaceToo (m_Offsets [i]);
			}
		}
	}
	
	public void ChangeFaceFloat (float face) 
	{
		Debug.Log ("ChangeFaceFloat: " + face);
		
		ChangeFaceToo (m_Offsets [(int)face]);
	}
}

Then i used the animation editor to link the string of the character animation(exmple: jump) to the facial animation(exmple: close eye) ,

But when i press play, character animation(jump) seems to play just fine while the facial animation(close eye) doesnt seems to play at all even though there is no error.

please help :frowning:

i tried applying the animation script in the facial mesh as well but still not working. :frowning:

Free Bump :slight_smile:

So where do you tell it to change/play the UV animation?
UV animation is nothing to do with the bones/rigged animation, in fact it could be on any gameobject in the scene, as long as it has reference to the material it is supposed to be animating.

Thank you for replying, well basically i told it to change the uv on the Facial mesh(game_rig_smile from the jpeg above), and it have no problem playing on individually as a facial script.

But the problem comes when i try make the the uv animation triggered when the character animation is played. and i tried approach that using the animation editor in unity. and apply the string to offset the UV every time the animation is played.

Or is my approach incorrect? your suggestion is much appreciated.

and i forgot to mention that the character animation script is in the separate game object from the the facial script like on the hierarchy window jpeg above. Reason of doing that is because i dont want the body UV to be effected when the facial script plays.

again any suggestion is much appreciated. thank you.

bump