I'm doing a job at Unity where the goal is to detect facial expressions with Kinect. In Unity the default expression is "neutral" and depending on whether we change the expression to "smiling" or "suprendido" the face it shows should change.
I used a gameobject which I called Face and assigned several textures and wanted it to switch between them when we changed the expression, but for some reason it does not want to work.
I'm using C #. I initially defined:
public static Texture[] textures = new Texture[7];
public Texture neutral, smiling, happy, angry, sad, kissing, surprised;
public GameObject Face;
public Renderer rend;
No start I have this:
player = GameObject.Find ("Face");
textures[0] = neutral;
textures[1] = smiling;
textures[2] = happy;
textures[3] = angry;
textures[4] = sad;
textures[5] = sad;
textures[6] = surprised;
However he does not find the "Face", but I got it by the inspector. In the Update I then do:
ClassifyAndApply(numbers);
And this is defined further below:
private void SaveAnimUnits()
{
numbers[0] = _animUnits.LipRaiser;
numbers[1] = _animUnits.JawLowerer;
numbers[2] = _animUnits.LipStretcher;
numbers[3] = _animUnits.BrowLowerer;
numbers[4] = _animUnits.LipCornerDepressor;
numbers[5] = _animUnits.OuterBrowRaiser;
}
private void ClassifyAndApply(float[] units){
// Renderer rend = GetComponent<Renderer>();
// Face = GameObject.Find ("Face");
if (units[2] <= 0.264888){
if (units[3] <= 0.817408){
if (units[1] <= 0.181886){
if (units[0] <= -0.216908){
if (units[4] <= 0.395523){
if (units[1] <= 0.104226){
Face. GetComponent<Renderer>().material.mainTexture = textures[3];
}
else{
Face. GetComponent<Renderer>().material.mainTexture = textures[0];
}
This continues, it's just a bit of the decision tree. The problem is that it does not change the texture when I make the expressions.
All help is welcome! Thanks