1、Create | Animator Controller
当采用键盘操控方式,所生成的Animation Controller可对动画效果予以控制
2、混合树
Blend Tree,平滑地混合多个动画
对大多数动画节点相比,Blend Tree节点则更为负责
双击时,新节点将显示于Animator窗口中,可对复杂的角色动画进行整合操作
3、维度
Blend Tree配置为一维节点,即在线性动画序列间执行混合操作,可在Object Inspector中查看设置
4、映射浮点值
运动行为的2D轴向针对Blend Tree中的角色加以定义
随后,需要两个浮点参数,并对源自脚本的混合动画加以控制
用于确定和控制骨骼化角色所播放的动画
5、编写基于Blend Tree的脚本
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharControl : MonoBehaviour { private Animator ThisAnimator = null; private int HorzFloat = Animator.StringToHash("Horz"); private int VertFloat = Animator.StringToHash("Vert"); private void Awake() { ThisAnimator = GetComponent<Animator>(); } // Use this for initialization void Start () { } // Update is called once per frame void Update () { float Vert = Input.GetAxis("Vertical"); float Horz = Input.GetAxis("Horizontal"); ThisAnimator.SetFloat(HorzFloat, Horz, 0.2f, Time.deltaTime); ThisAnimator.SetFloat(VertFloat, Vert, 0.2f, Time.deltaTime); } }