Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Animator.SetFloat with damp goes crazy

Discussion in 'Animation' started by Vefery, Jan 7, 2020.

  1. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    101
    Here's the problem: I have animator with blendTree (idle-walk-run), walk and run animations have footstep animation events, I use SetFloat to control parameter that controls blendTree.
    With damp value 0: everything works perfectly, animations play correctly, footstep events fire only while walk/run animations. But transition is very jittery.
    With damp value other than 0: when I walk and then release button, character smoothly stops but animation events still fire. In animator blendTree's value smoothly goes to 0 and when it almost reaches 0 it goes crazy to 5-6. It doesn't affect animations visually but because of that footstep events still fire
     
  2. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    101
    Bump
     
  3. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    101
    Bump x2
     
  4. uacaman

    uacaman

    Joined:
    Mar 9, 2014
    Posts:
    4
    Bump x3
     
  5. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    420
    Bump x4, I'm getting this same issue. Exact same problem actually.

    Edit
    Here's how I fixed it for me at least. It's working for now but it's 3am and I haven't tested it extensively so who knows.
    Code (CSharp):
    1. if (animator.GetFloat(Forward) > 0.1 || forwardAmount > 0)
    2. {
    3.  animator.SetFloat(Forward, forwardAmount, 0.2f, Time.deltaTime);
    4. }
    5. else if (forwardAmount == 0)
    6. {
    7.  animator.SetFloat(Forward, 0);
    8. }
     
    Last edited: Jul 7, 2021
unityunity