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