public IEnumerator AttackCoroutine() { GameObject hitbox = Instantiate(hitboxPrefab); hitbox.transform.position = currentTarget.position; SmashMonoBehaviour smb = hitbox.GetComponent <SmashMonoBehaviour>(); smb.damage = attackDamage; smb.countdownTimer = attackWindup; for (float i = attackWindup; i > 0.0f; i -= Time.deltaTime) { yield return(null); } for (float i = attackCooldown; i > 0.0f; i -= Time.deltaTime) { yield return(null); } isAttacking = false; }
public IEnumerator SmashAttackCoroutine() { animator.SetInteger(actionState, (int)ActionState.SMASHING); // PARAMS float attackPointCountdown = 0.8f; float backswingCountdown = 0.2f; // ATTACK GameObject smash = Instantiate(smashPrefab); smash.transform.position = target.transform.position; SmashMonoBehaviour smb = smash.GetComponent <SmashMonoBehaviour>(); smb.damage = smashDamage; rigidBody.constraints = RigidbodyConstraints2D.FreezeAll; // ATTACK POINT smb.countdownTimer = attackPointCountdown; while (attackPointCountdown > 0.0f) { attackPointCountdown -= Time.deltaTime; yield return(null); } // ATTACK BACKSWING while (backswingCountdown > 0.0f) { backswingCountdown -= Time.deltaTime; yield return(null); } rigidBody.constraints = RigidbodyConstraints2D.FreezeRotation; DetermineNextAction(); }