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 int spriteAtual, so the code will update the Sprite according to the value of int, then just change the sprites of the array "sprites" in the inspector and reuse code and animation without needing anything else. If you still want to change the sprites by code you can still create multiple arrays 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 has the same animation synchronized, in which case you will have to duplicate the Animator for each character to be independent
I've created the codes on the phone, so there may be errors, (mainly because I do not know if a method that returns an array is possible) but the important thing is to understand the idea and reproduce it yourself, p>