Animator是否有isPlaying()类型函数

时间:2014-05-03 20:32:39

标签: c# animation unity3d

我知道你可以做动画。播放()但Animator有类似的东西吗?如果我有:

Animator animator;

void Start()
{
    animator = GetComponenet<Animator>();
}

然后我可以去:

void Update()
{
    if(Input.GetMouseButtonDown(0))

        Instantiate(shot, shotSpawn.position, shotSpawn.rotation);

            if(!animator.isPlaying("ShootAnimation"))
            {
                animator.SetTrigger("ShootAnimation"); // play shooting animation
            }
    }
}

1 个答案:

答案 0 :(得分:1)

if (animator.GetCurrentAnimatorStateInfo(0).IsName("YourAnimationName"))
{
    // do your magic
}