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);
}
}