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