- Home /
Animation from 3rd layer not playing
Hey there, I have an animator with 3 layers: Body, Arms and Weapons. Body and Arms work perfectly, however, the Weapons layer looks like it's playing to (I see the blue bar) but it doesn't play in the scene, could anyone tell me why?
void Update() {
if (Input.GetButtonDown("Slot1") && !weaponEquipped)
{
animator.Play("equipM4A4", 2);
weaponEquipped = true;
Debug.Log("weapon equip");
}
else if (Input.GetButtonDown("Slot1") && weaponEquipped)
{
animator.Play("unequipM4A4", 2);
weaponEquipped = false;
Debug.Log("weapon unequip");
}
else if (!weaponEquipped && !AnimationIsPlaying(animator, "unequipM4A4", 2))
animator.Play("idleM4A4", 2);
else if (!AnimationIsPlaying(animator, "equipM4A4", 2))
animator.Play("equippedIdleM4A4", 2);
}
Don't think it's a code thing but an Animator layer thing or animation thing since the code seems to be calling the animation.Is the weapons layer set to 100% override? default when creating the layer is set to 0. Been a while since I have done layers...does the layer order matter? like top layer has priority and is weapon layer on top ( just a guess). $$anonymous$$aybe don't understand the question....Is the weapon layer an actual weapon or a body part of the character you want to override when he has a weapon
Wow! I put it on additive and it didn't work, when I changed it to override it started working. Why? All the other layers are set to additive, and they worked. Can you please post it as an answer and explain to me why? And also so I can mark it as the right answer.
Answer by shadowpuppet · May 02, 2020 at 03:39 PM
I don't know why. perhaps additive works because the two animations aren't very conflicting between the body and arms. Additive is a blend of existing animation on main layer and that of the additive layer. In the case of a weapon - where he has it or he doesn't, you'd want that layer to over ride or do nothing. You'd want 100% of that layer . That is as best as I can explain. Not had much luck in additive. I can see it if you , say, have two walk cycles. One where the character is walking normally , and on another layer he is walking as if he had a huge weight on his shoulders - literally or figuratively. Like he is sad or tired then that layer additive to the base layer - probably even change the blend in code as he gets more tired. But if holding a weapon that should take priority