void OnCollisionEnter(Collision collisionInfo) { if (collisionInfo.gameObject == attackTank) { return; } GameObject obj = (GameObject)Instantiate(explodeEffect, transform.position, transform.rotation); AudioSource explodeSrc = obj.AddComponent <AudioSource> (); explodeSrc.spatialBlend = 1; explodeSrc.PlayOneShot(explodeClip); if (collisionInfo.gameObject != null) { Tank tk = collisionInfo.gameObject.GetComponent <Tank> (); if (tk != null) { tk.BeAttcked(attackTank); } } Destroy(gameObject); }