private void UpdateAttackAnimation() { if (attackAnimationState == AttackAnimationState.GOING_BACKWARDS) { backwardsVector2Lerper.Update(); transform.GetChild(0).localPosition = backwardsVector2Lerper.CurrentValue; if (backwardsVector2Lerper.Reached) { attackAnimationState = AttackAnimationState.GOING_FORWARD; forwardVector2Lerper = new Vector2Lerper(transform.GetChild(0).localPosition, target.transform.position - transform.position, 0.05f); forwardVector2Lerper.SetValues(transform.GetChild(0).localPosition, target.transform.position - transform.position, true); } } else { forwardVector2Lerper.Update(); transform.GetChild(0).localPosition = forwardVector2Lerper.CurrentValue; if (forwardVector2Lerper.Reached) { attackAnimationState = AttackAnimationState.NOT_PLAYING; DamageCallback(); AudioController.instance.PlayPunchSound(); //The amount of time we want the footman to be on the enemy Invoke("ResetAttackPosition", 0.3f); } } }
public override void PlayAttackAnimation() { animator.enabled = false; attackAnimationState = AttackAnimationState.GOING_BACKWARDS; backwardsVector2Lerper = new Vector2Lerper(new Vector2(0f, 0f), -GetAttackingDirection() / 8, 0.3f); backwardsVector2Lerper.SetValues(new Vector2(0f, 0f), -GetAttackingDirection() / 8, true); }