What you can do is create a Script like the following:
public int spriteAtual;
public Sprite[] sprites;
private SpriteRenderer img;
void Start
{
img = gameObject.getComponent<SpriteRenderer>();
}
void Update
{
img.Sprite = sprites[spriteAtual];
}
And in the animation you only change the value of the int spriteAtual, so the code will update the Sprite according to the value of the int, then just change the sprites of the matrix "sprites" in the inspector and reuse the code and animation without needing anything else. If you still wanted to change the sprites by code you can also create several matrices and use the Switch function as below
public int animacaoX;
public int spriteAtual;
public Sprite[] spritesDaAnimacaoX;
public Sprite[] spritesDaAnimacaoX2;
public Sprite[] spritesDaAnimacaoX3;
private SpriteRenderer img;
void Start
{
img = gameObject.getComponent<SpriteRenderer>();
}
void Update
{
img.Sprite = animacaoAtual(animacaoX)[spriteAtual];
}
Sprite[] AnimacaoAtual()
{
Switch qualAnimacao
case 1:
return spritesDaAnimacaoX[];
break;
case 2:
return spritesDaAnimacaoX2[];
break;
case 3:
return spritesDaAnimacaoX3[];
break;
}
If you use the same Animator for more than one character it may be that everyone gets the same synchronized animation, in which case you have to duplicate the Animator for each character to be independent
NOTE: I created the codes by cell phone, so there may be errors, (mainly pq do not know if it is possible a method that returns an array) but the important thing is to understand the idea and reproduce yourself, I hope to have helped.