void attackPlayer() { //Vector3 dir = Vector3.Normalize(target.position - myTransform.position); //float direction = Vector3.Dot (dir, transform.forward); if (coolDownTimer == 0) { ph.ChangeHealth(damage); coolDownTimer = 3; } }
void attackPlayer() { Vector3 dir = Vector3.Normalize(target.position - myTransform.position); float direction = Vector3.Dot(dir, transform.forward); if (direction > 0) //enemy is in front of us { if (coolDownTimer == 0) { ph.ChangeHealth(damage); coolDownTimer = 3; } } }