1.I have written an script that uses ontriggerenter to find when a cannon ball hits another ship in a 2D game.
private void OnTriggerEnter(Collider other)
{
To ignore collision, use Physics.IgnoreCollision.
There is also Physics.IgnoreLayerCollision which is used to ignore collisions on layers.
Just put all the Objects you want to ignore in a layer then invoke the function to ignore layers on them.
Ignore Collison 3D:
Physics.IgnoreCollision(yourFirstCollider, yourSecondCollider, true)
or
Physics.IgnoreLayerCollision(yourFirstLayer, yourOtherLayer, true);
Reset/Recognize Collison 2D:
Physics2D.IgnoreCollision(yourFirstCollider, yourSecondCollider, false);
or
Physics2D.IgnoreLayerCollision(yourFirstLayer, yourOtherLayer, false)
Both layers do not have to be the-same. You can ignore collision on Objects from different layers. This can also be accomplished through the Editor without code by assigning each GameObject layer and going to Edit --> Project Settings --> Physics --> or Edit --> Project Settings --> Physics 2D then configure which layers should collide with one another from there.