void AttackOrBarricade() { if (!coolDown) { RaycastHit2D hit = Physics2D.Raycast(new Vector2(transform.position.x, transform.position.y), (Vector2.right / 30), stikeDistance); if (hit) { if (hit.collider.gameObject.CompareTag("enemy")) { print("hit enemy"); PlayAudio(punchHit); hit.collider.gameObject.GetComponent <EnemyAI>().DamageEnemy(damage); SpawnNumber(damage, hit.collider.gameObject.transform.position); } if (hit.collider.gameObject.tag == "Barricade") { print("build barricade"); BarricadeReference.BuildBarricade(); } } else { PlayAudio(punchMiss); youShallNotPass = false; } coolDown = true; anim.SetInteger("animState", 2); Invoke("AttackCoolDown", coolDownRateInSeconds); } }