unity新舊動(dòng)畫(huà)系統(tǒng)的控制

一.Legacy舊動(dòng)畫(huà)系統(tǒng)

1.rig中選擇Legacy
Paste_Image.png
2.animate中切好動(dòng)畫(huà)
Paste_Image.png
3.點(diǎn)擊場(chǎng)景中的模型,可以看到Animation自動(dòng)把動(dòng)畫(huà)添加進(jìn)來(lái)了
Paste_Image.png
4.根據(jù)動(dòng)畫(huà)名字,增加腳本控制播放
using UnityEngine;
using System.Collections;

public class oldAnimateSystem : MonoBehaviour {


    public Animation m_Animate;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.GetKey(KeyCode.W)){

            m_Animate.Play("WalkBackward01");

        }
        if (Input.GetKey(KeyCode.S))
        {

            m_Animate.Play("WalkBackward02");

        }
    }
}

二.Humnoid

1.Rig中選中舊動(dòng)畫(huà)Humnoid
Paste_Image.png
2.animate中切好動(dòng)畫(huà)
Paste_Image.png
3.創(chuàng)建狀態(tài)機(jī)

把模型拉入場(chǎng)景中,模型就自動(dòng)有了Animator


Paste_Image.png

創(chuàng)建一個(gè)Animator Controller并賦予Animator的Controller


Paste_Image.png
4.編輯狀態(tài)機(jī)

把自己想要的動(dòng)畫(huà)拉入狀態(tài)機(jī)


Paste_Image.png
5.設(shè)置狀態(tài)機(jī)參數(shù)

增加一個(gè)你想要切換的參數(shù)


Paste_Image.png
4.增加腳本控制
using UnityEngine;
using System.Collections;

public class newAnimtionController : MonoBehaviour {
    public Animator mAnim;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
        if (Input.GetKey(KeyCode.W))
        {

            mAnim.SetFloat("change", 0);
            print("0");

        }
        if (Input.GetKey(KeyCode.S))
        {

            mAnim.SetFloat("change", 1);
            print("1");

        }
    }
}



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容