/// <summary> /// OnTriggerEnter is called when the GameObject collides with another GameObject. /// </summary> /// <param name="other"> A Collider involved in this collision. </param> void OnTriggerEnter(Collider other) { if ((other.tag == "Player") && (state != 1)) { isPlayerInRange = true; playerHealth = other.gameObject.GetComponent <PlayerHealth>(); } else if (other.tag == "Bat") { playerBatSwing = other.gameObject.GetComponentInChildren <BatSwing>(); } else if ((other.tag == "Enemy") && (state != 2)) { isEnemyInRange = true; enemyHealth = other.gameObject.GetComponent <EnemyHealth>(); } else if (other.tag == "Despawner") { DestroyBall(); } else if (other.tag == "Breakable") { Destroy(other.gameObject); DestroyBall(); } }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { playerMovement = GetComponent <PlayerMovement> (); playerCollider = GetComponents <Collider> (); batSwing = GetComponentInChildren <BatSwing>(); batGuard = GetComponentInChildren <BatGuard>(); currentHealth = startingHealth; }