I’ve created a system where a player can equip diferent clothes and it will change the player appearence ingame.
There is a sprite in which the player is naked and on top there is a specific sprite for each clothing type with an animatorOverride.
In this Image I only have the Leg and Torso socket created.
They have an AnimatorOverride that will recieve an animationClip array with all the animations for each specific item and change them in-game.
This is working fine, the problem is that I would need to create diferent aniamtionClip for each item with all the player animations .
Right now there is 16 animations, 4 unarmed idles 4 armed Idles 4 walking unarmed 4 armed idle so it would take a massive amount of time to create AnimationClips for each item like this, it would require 16 AnimationClips per item.
The sprites are all in a SpriteSheet like so:
Is there a way to have just one animationClip for each type and change its sprites on the go?
Is there other simplier way to do this?
Here is a part of the code this one Changes the clips on the animatorOverride to the correctOnes
public void Equip(AnimationClip[] animations)
{
spriteRenderer.color = Color.white;
legsAnimatorOverrideController["PlayerLeftIdle"] = animations[0];
legsAnimatorOverrideController["PlayerRightIdle"] = animations[1];
legsAnimatorOverrideController["PlayerStanding"] = animations[2];
legsAnimatorOverrideController["playerStandingDownArmed"] = animations[3];
legsAnimatorOverrideController["playerStandingLeftArmedIdle"] = animations[4];
legsAnimatorOverrideController["playerStandingRightArmedIdle"] = animations[5];
legsAnimatorOverrideController["playerStandingUpArmed"] = animations[6];
legsAnimatorOverrideController["playerStandingUpArmedIdle"] = animations[7];
legsAnimatorOverrideController["PlayerUpIdle"] = animations[8];
legsAnimatorOverrideController["PlayerWalkingDown"] = animations[9];
legsAnimatorOverrideController["PlayerWalkingDownArmed"] = animations[10];
legsAnimatorOverrideController["PlayerWalkingLeft"] = animations[11];
legsAnimatorOverrideController["PlayerWalkingLeftArmed"] = animations[12];
legsAnimatorOverrideController["PlayerWalkingRight"] = animations[13];
legsAnimatorOverrideController["playerWalkingRightArmed"] = animations[14];
legsAnimatorOverrideController["PlayerWalkingUp"] = animations[15];
}
And this one is going to get the correct animationClips from the resources folder
tempObj0 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "0");
tempObj1 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "1");
tempObj2 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "2");
tempObj3 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "3");
tempObj4 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "4");
tempObj5 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "5");
tempObj6 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "6");
tempObj7 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "7");
tempObj8 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "8");
tempObj9 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "9");
tempObj10 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "10");
tempObj11 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "11");
tempObj12 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "12");
tempObj13 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "13");
tempObj14 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "14");
tempObj15 = Resources.Load<AnimationClip>("Animations/" + tempSlug + "15");
legsAnimationclips[0] = tempObj0;
legsAnimationclips[1] = tempObj1;
legsAnimationclips[2] = tempObj2;
legsAnimationclips[3] = tempObj3;
legsAnimationclips[4] = tempObj4;
legsAnimationclips[5] = tempObj5;
legsAnimationclips[6] = tempObj6;
legsAnimationclips[7] = tempObj7;
legsAnimationclips[8] = tempObj8;
legsAnimationclips[9] = tempObj9;
legsAnimationclips[10] = tempObj10;
legsAnimationclips[11] = tempObj11;
legsAnimationclips[12] = tempObj12;
legsAnimationclips[13] = tempObj13;
legsAnimationclips[14] = tempObj14;
legsAnimationclips[15] = tempObj15;