What is the difference between Collider2D & Collision2D ?

Why this is happening, when I use collision.tag in onTriggerEnter2d or onTriggerExit2D it’s fine but not in onCollisionEnter2D.

I have to use collision.gameObject.tag, that’s a real trick but why trigger allowing me to use collision.tag without defining a gameObject.

or explain me a collider2D and collision2D library

Collider2D is the component in the scene that defines the physical shape. When you enter the trigger, that’s the only information you get - what collider entered the trigger.


In Collision, you get the Collision2D object - it contains more detailed information about the collision; where exactly, what force was exerted at each contact point, etc. It also includes the collider and the gameObject.


To remove the confusion, just rename the collision argument in the OnTriggerEnter2D to collider, that would be more correct.

The trigger function returns the collider class and the Collision function returns the Collision parameters. A collider has tag so you can access it directly but collision class contains data such as collision points, gameobject etc. So to access tag, you need to use collision.gameObject.tag

Here is a guide to Unity Collision for beginners for better understanding.