【发布时间】:2021-07-28 01:28:12
【问题描述】:
我有一个使用双向动画的层(层名称是“基础层”)
要让 2 工作,1 必须完成运行。下面的源码应该怎么添加?
(1-direction由一个变量触发,当我用鼠标右键单击时,该变量为真)
//the function is called inside the update method
private void PunchAnim()
{
if (_hasAnimator)
{
if (_input.punch)
{
_animator.SetBool(_animIDPunch, true);
}
}
}
我试过了,但是没用
private void PunchAnim()
{
if (_hasAnimator)
{
if (_input.punch)
{
_animator.SetBool(_animIDPunch, true);
int baseLayerIndex =_animator.GetLayerIndex("Base Layer");
if (_animator.GetCurrentAnimatorStateInfo(baseLayerIndex).IsName("Punch") && _animator.GetCurrentAnimatorStateInfo(baseLayerIndex).normalizedTime < 1.0f)
{
//still working
}
else
{
_animator.SetBool(_animIDPunch, false);
}
}
}
【问题讨论】: