Unity - Curves 与Paramters联动使用 - 对动画文件(.fbx)的Animaion添加Curves的使用方式
程序员文章站
2022-07-13 22:07:27
...
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;
}
}
}
给状态机添加参数:float scale = 1
再对应的fbx动画中,对应的Animation的下方的Curves添加对scale的动画曲线值控制
Runtime
正常的跑步动画,不应用scale曲线值
应用scale曲线值来控制localScale的运行效果