- Home /
Dynamically add / remove layers from animation controller through script
I'm working on an RPG game where the player can equip different weapons, which each have different animations for attacking, moving, etc. which play on an avatar mask that corresponds to where the weapon is equipped, e.g. a one-handed sword's animations would affect the right arm & chest, while a two-handed bow would affect the torso and both arms.
The way I currently have it set up is that each weapon stores a reference to a different animator controller, which all have the animations layers which hold that weapon's animations, as well as a layer for the base animations (the basic walk / jump/ etc. animations that affect the whole rest of the body). When the weapons are equipped, the player's animator controller is swapped out for the weapon's controller.
This works fine, however I don't really like the concept of storing the base layer separately on each of these controllers, because then if I change the base animations for one controller, it won't affect the others, when it probably should. Like for example if I wanted to change the way the jumping / falling animations worked, I would have to do that for all of the different animator controllers, which is not ideal.
Would it be possible to just copy the necessary layers from the weapon animator controllers and apply them to the player's controller when the weapons are equipped, or is there another way for me to do this? I'm really struggling to find out how to make this work better.
Your answer
Follow this Question
Related Questions
Display additional animation on top of other animations 0 Answers
Playing two animations simultaneously that both alter the same sprite image? 1 Answer
Make animation go to child.,Make animation go to child 1 Answer
Animation Samples Rate Can't Able to Find Unity 2019 1 Answer
Change Animator Parameters on Different Object - Prefabs 1 Answer