Unity - Curves and Paramters joint use - Animaion for animation files (.fbx) added use of Curves

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/linjf520/article/details/90675949

Code

using UnityEngine;

public class ReadAnimCurves : MonoBehaviour
{
    public bool appliedScaleCurve;
    private Animator animator;
    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        if (appliedScaleCurve)
        {
            var s = animator.GetFloat("scale");
            transform.localScale = new Vector3(s, s, s);
        }
        else
        {
            transform.localScale = Vector3.one;
        }
    }
}

Is added to the state machine parameters: float scale = 1

Here Insert Picture Description

fbx corresponding animation again, Curves Animation below the corresponding value of the control curve to add animation to the scale

Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture Description

Runtime

Normal running animation, do not use scale value curve
Here Insert Picture Description

Application of scale effect curve values ​​controlling the operation of localScale
Here Insert Picture Description

References

Unity animation control curve was added

Guess you like

Origin blog.csdn.net/linjf520/article/details/90675949