animator.SetFloat transitioning too fast... (Blend Tree)

Heyo,

In Play mode, the Grounded Blend parameter is transitioning from “0” to “9” instantly instead of smoothing between the two floats…

I’m using the following script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterAnim : MonoBehaviour
{

 
    public GameObject player;
    private Animator anim;

    // Start is called before the first frame update
    void Start()
    {
        anim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
        {
            anim.SetFloat("Grounded Blend", 9f);
        }

        else
        {
            anim.SetFloat("Grounded Blend", 0f);
        }
    }

    void FixedUpdate()
        {
         
        }
}

Any thoughts or ideas would be greatly appreciated…

This is Unity 2019.4.8f1

For anyone curious, I ended up fixing this by adding this structure to my script:

public void SetFloat(string name, float value, float dampTime, float deltaTime);

So now it looks like this:

void Update()
    {
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
        {
                        //(string name, float value, float dampTime, deltaTime)
            anim.SetFloat("Grounded Blend", .1f, .1f, Time.deltaTime);
        }

        else
        {
            anim.SetFloat("Grounded Blend", 0f, .1f, Time.deltaTime);
        }
    }
1 Like