private void OnCollisionEnter(Collision other) { print("Player has collided with: " + other.gameObject.tag); // If we are in the air when we collide with something if (!onGround) { switch (other.gameObject.tag) { case Tags.MINION: if (playerController.doingGroundPound) { other.gameObject.GetComponent <HealthController>().Die(); } else { other.gameObject.GetComponent <HealthController>().RemoveHealth(1); playerController.Bounce(); } break; case Tags.BARRELL: if (!playerController.doingGroundPound) { playerController.Bounce(); } break; case Tags.CRATE: if (!playerController.doingGroundPound) { playerController.Bounce(); } break; } } switch (other.gameObject.tag) { case Tags.GROUND: // If we hit the ground as we are doing a ground pound if (playerController.doingGroundPound) { // Shake the camera and play the dust particleController.PlayGroundPound(); CameraController.instance.ShakeCamera(.4f, .5f); GetComponent <PlayerUIController>().RechargeGroundPound(); // Inflict damage upon enemies in range //Collider[] objectsInRange = Physics.OverlapBox(feetPosition.position, new Vector3(playerController.groundPoundRadius, .5f, 5f)); Collider[] objectsInRange = Physics.OverlapCapsule(feetPosition.position, feetPosition.position + Vector3.up / 10, playerController.groundPoundRadius); for (int i = 0; i < objectsInRange.Length; i++) { GameObject obj = objectsInRange[i].gameObject; switch (obj.tag) { case Tags.MINION: Vector3 direction = obj.transform.position - transform.position; direction = -direction.normalized; obj.gameObject.GetComponent <HealthController>().RemoveHealth(1); obj.gameObject.GetComponent <Minion>().KnockBack(direction); break; case Tags.BARRELL: obj.GetComponent <DestroyableObject>().Destroy(); break; case Tags.CRATE: obj.GetComponent <DestroyableObject>().Destroy(); break; } } } else { if (!onGround) { particleController.PlayJumpDust(); } } onGround = true; particleController.PlayFeetDust(); break; case Tags.MINION: if (onGround) { GetComponent <HealthController>().RemoveHealth(1); } break; case Tags.BULLET: GetComponent <HealthController>().RemoveHealth(1); break; case Tags.PICKUP_BLASTER: GetComponent <PlayerWeaponsController>().ChangeWeapon("Blaster"); Destroy(other.gameObject); break; case Tags.PICKUP_CANNON: GetComponent <PlayerWeaponsController>().ChangeWeapon("Cannon"); Destroy(other.gameObject); break; case Tags.PICKUP_DYNAMITE: GetComponent <PlayerWeaponsController>().hasDynamite = true; GetComponent <PlayerUIController>().SetDynamiteIcon(true); Destroy(other.gameObject); break; case Tags.CHECKPOINT: Checkpoint c = other.gameObject.GetComponent <Checkpoint>(); GetComponent <PlayerCheckpointController>().UpdateCheckpoint(c); c.Animate(); break; } }