在animator下增加子状态机(攻击状态)
可以指明跳到子状态机的具体哪一个或者把决定权交给子状态机;利用标签进行查核目前是不是运行到带有这种标签的状态,利用代码查核:
修改actorcontrller的攻击系统:
/// <summary>
/// Attack
/// </summary>
public void OnAttackEnter()
{
pi.inputEnabled = false;
// lockPlanar = false;
//lerpTarget = 1.0f;
}
public void OnAttack1hAUpdate()
{
thrustVec = model.transform.forward * anim.GetFloat("attack1hVelocity");
//float currentWeight = anim.GetLayerWeight(anim.GetLayerIndex("attack"));//找到此刻的权重
//currentWeight = Mathf.Lerp(currentWeight, lerpTarget, 0.3f);//此刻的权重 以50%当速度增长
//anim.SetLayerWeight(anim.GetLayerIndex("attack"), currentWeight);//用查找层级索引的方法修改层级的权重
}
public void OnUpdateRM(object _deltaPos)
{
//print((Vector3) _deltaPos);
if (CheckState("attack1hC"))//只有这一动作执行这一部分
{
deltaPos += (0.2f * deltaPos + 0.8f * (Vector3)_deltaPos) / 1.0f;//将动画里面的位移给到deltapos等待fixupdate更替position} //相加除以二是因为减小摄像机晃动
}
}
}