void ParryAction(Action slot) { string targetAnim = null; targetAnim = slot.GetActionStep(ref actionManager.actionIndex).GetBranch(slot.input).targetAnim; if (string.IsNullOrEmpty(targetAnim)) { return; } float targetSpeed = 1; if (slot.changeSpeed) { targetSpeed = slot.animSpeed; if (targetSpeed == 0) { targetSpeed = 1; } } anim.SetFloat("animSpeed", targetSpeed); // exit the function after playing the animation. canBeParried = slot.canBeParried; canAttack = false; onEmpty = false; canMove = false; // canMove = false to use the RootMotion. inAction = true; anim.SetBool("mirror", slot.mirror); anim.CrossFade(targetAnim, 0.2f); }
void AttackAction(Action slot) { if (characterStats._stamina < 5) { return; } if (CheckForParry(slot)) { return; } if (CheckForBackStab(slot)) { return; } string targetAnim = null; ActionAnim branch = slot.GetActionStep(ref actionManager.actionIndex).GetBranch(storeActionInput); targetAnim = branch.targetAnim; audio_clip = ResourceManager.singleton.GetAudio(branch.audio_ids).audio_clip; if (string.IsNullOrEmpty(targetAnim)) { return; } currentAction = slot; canBeParried = slot.canBeParried; canAttack = false; onEmpty = false; canMove = false; inAction = true; float targetSpeed = 1; if (slot.changeSpeed) { targetSpeed = slot.animSpeed; if (targetSpeed == 0) { targetSpeed = 1; } } anim.SetFloat("animSpeed", targetSpeed); anim.SetBool("mirror", slot.mirror); anim.CrossFade(targetAnim, 0.2f); characterStats._stamina -= slot.staminaCost; // rigid.velocity = Vector3.zero -> instead of turning off the velocity, we add velocity AnimatorHook.cs }