- Home /
How to change animator layers smoothly?
Hello !
I have a problem , in my game, I want to change a animator layers (between 3) smoothly but it is very jerky. I use 3 different animation layers and in my script I use setLayerWeight and to make it slower, I use SmoothDamp, how to make it less jerky? I think I can't handle more than one animation layer on the same animator component at the same time.
Thank you in advance for your help. I will continue to do research until I receive your answer.
void ChangeWeapon() { currentInjuredLayerWeight = handAnim.GetLayerWeight(bowLayerIndex); yo = handAnim.GetLayerWeight(knifeLayerIndex); targetInjuredLayerWeight = bb;
vv = cc;
// 0 = sword && 1 = bow
if(currentWeapon == 0)
{
//handAnim.SetLayerWeight(1, 0f);
sword.SetActive(true);
bow.SetActive(false);
knife.SetActive(false);
bb = 0;
cc = 0;
}
else if(currentWeapon == 1)
{
//handAnim.SetLayerWeight(1, 1f);
sword.SetActive(false);
bow.SetActive(true);
knife.SetActive(false);
bb = 1;
cc = 0;
}
else if (currentWeapon == 2)
{
//handAnim.SetLayerWeight(1, 1f);
knife.SetActive(true);
sword.SetActive(false);
bow.SetActive(false);
cc = 1;
bb = 0;
}
handAnim.SetLayerWeight(bowLayerIndex, Mathf.SmoothDamp(currentInjuredLayerWeight, targetInjuredLayerWeight, ref layerWeightVelocity, 0.2f));
handAnim.SetLayerWeight(knifeLayerIndex, Mathf.SmoothDamp(yo, vv, ref layerWeightVelocity, 0.2f));
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613055342im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animator Override Controller Layer Issue 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers
Issue with animation 1 Answer
Sprite Animation Controller Layer on top of each other? 0 Answers