void OnTriggerEnter2D(Collider2D collider) { HeroRabbit rabbit = collider.GetComponent <HeroRabbit>(); if (rabbit != null) { // angle check Vector3 dir = collider.transform.position - transform.position; dir = collider.transform.InverseTransformDirection(dir); float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; if (angle < 60 || angle > 120) { if (rabbit.invulnerableTime <= 0) { if (rabbit.isBig) { animator.SetTrigger("attack"); rabbit.DecreaseRabbitSize(); rabbit.invulnerableTime = 4; } else { animator.SetTrigger("attack"); rabbit.isAlive = false; } } } else { // orc dies animator.SetTrigger("die"); isAlive = false; rabbit.TossRabbitUp(); StartCoroutine(dieLater()); } } }