IEnumerator MeleeAttack(Collider[] hitPlayers) { Debug.Log("Performing Melee Attack"); ready2Atttack = false; foreach (var player in hitPlayers) { // Apply knock-back force at each player //Rigidbody body = player.gameObject.GetComponent<Rigidbody>(); //body.AddForce( transform.forward * knockbackForce, ForceMode.Impulse); Player1 enemy = player.gameObject.GetComponent <Player1>(); enemy.ApplyKnockBack(transform.forward * knockbackForce, true, 1.0f); } yield return(new WaitForSeconds(attackRate)); ready2Atttack = true; }