Check out example codes for "unity 2d collision". It will help you in understanding the concepts better.

Code Example 1

void OnCollisionEnter2D(Collision2D col) {
  Debug.Log("Collided with: " + col.gameObject.name);
}

Code Example 2

void OnCollisionEnter2D(Collision2D col)
    {
		//This method will run when your 2D game object
      	//collides with something

      	Debug.Log("Collided");
    }

Code Example 3

using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour {
    void OnCollisionEnter2D(Collision2D coll) {
        if (coll.gameObject.tag == "Enemy")
            coll.gameObject.SendMessage("ApplyDamage", 10);
        
    }
}

Code Example 4

void OnCollisionEnter2D(Collision2D coll){)

Learn ReactJs, React Native from akashmittal.com