void TryToAttack() { if (attackTarget != null) { if (Time.time > nextAttack) { nextAttack = Time.time + attackRate; if (Vector3.Distance(myTransform.position, attackTarget.position) <= attackRange) { Vector3 lookAtVector = new Vector3(attackTarget.position.x, myTransform.position.y, attackTarget.position.z); myTransform.LookAt(lookAtVector); enemyMaster.CallEventEnemyAttack(); enemyMaster.isOnRoute = false; } } } }
void TryToAttack() { if (attackTarget != null) { if (Time.time > nextAttack) { nextAttack = Time.time + attackRate; if (Vector3.Distance(myTransform.position, attackTarget.position) <= attackRange) { int index = Random.Range(0, golemAttack.Length); AudioSource.PlayClipAtPoint(golemAttack[index], myTransform.position); Vector3 lookAtVector = new Vector3(attackTarget.position.x, myTransform.position.y, attackTarget.position.z); myTransform.LookAt(lookAtVector); enemyMaster.CallEventEnemyAttack(); enemyMaster.isOnRoute = false; } } } }