private void OnCollisionEnter(Collision collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("Tank")) { TankController hitTank = collision.gameObject.GetComponent <TankController>(); if (hitTank) { if (hitTank.GetPlayer() != tankCtrl.GetPlayer()) { tankCtrl.ChangeWeapon(); hitTank.Kill(); } } Destroy(gameObject); return; } currentBounce++; if (currentBounce == maxBounce) { Destroy(gameObject); } else { Vector3 newDirection = Vector3.Reflect(transform.forward, collision.contacts[0].normal); transform.rotation = Quaternion.LookRotation(newDirection, Vector3.up); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.layer == LayerMask.NameToLayer("Tank")) { TankController hitTank = collision.gameObject.GetComponent <TankController>(); if (hitTank) { if (hitTank.GetPlayer() != tankCtrl.GetPlayer()) { tankCtrl.ChangeWeapon(); hitTank.Kill(); Destroy(gameObject); } } return; } Destroy(gameObject); }