Animator 多個鏡頭切換

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class Test : MonoBehaviour
{
    private Animator demo;
    private bool stop;
    // Start is called before the first frame update
    void Start()
    {

        demo = transform.GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
       
        if (stop == false)
        {
          
            if (Input.GetKeyDown(KeyCode.F1))
            {
                print("deee");
                demo.SetFloat("speed", 1);
                demo.Play("Move");
                stop = true;
            }
            if (Input.GetKeyDown(KeyCode.F2))
            {
                demo.SetFloat("speed", 1);

                demo.Play("Move1");
                stop = true;
            }
            if (Input.GetKeyDown(KeyCode.F3))
            {
                demo.SetFloat("speed", 1);

                demo.Play("Move2");
                stop = true;
            }
           
        }
        else
        {
            if (Input.GetMouseButtonDown(2))
            {
                StartCoroutine(Back());
            }
        }
      
    }
    IEnumerator Back()
    {
       
        demo.SetFloat("speed", -1);
        demo.Play(demo.GetCurrentAnimatorClipInfo(0)[0].clip.name);
        yield return new WaitForSeconds(demo.GetCurrentAnimatorClipInfo(0)[0].clip.length);
       
        stop = false;
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章