I cant get 2D collisions to work, but everything looks ok to me, any help please?

I am very new to unity and programming genrally but im trying to make a frogger like game, i cant get my player to hit any enemies, heres my script…

using UnityEngine;
using System.Collections;

public class DeathTrigger : MonoBehaviour {

void OnCollisionEnter (Collision col){
	
	if (col.gameObject.tag == "Enemy")
	{

		print ("Hit!");
	}
}

}

From all the online stuff ive read this should work, but im getting no joy, ive got two objects, both with box colliders 2D and both have rigidbody 2D’s.
Im probably missing something super simple but all the same…

This has been bugging me for a while and any help is more than welcome, thanks.

P.S. Using Unity Ver: 5.4.1 and writing in Csharp.

If I remember well, the documentation is misleading, or the Collision2D model is working like expected.

The .gameObject property will return the gameObject the component is on.
Try using .collider.gameObject instead.

void OnCollisionEnter (Collision col)
{
     if (col.collider.gameObject.tag == "Enemy")
     {
         print ("Hit!");
     }
 }

Thanks for the reply but it still doesnt work, like i said i am new to this, so are there any inspector settings i might have wrong?

The 2 screenshots are of the ‘truck’ or the enemy, and of the player.

Thanks again.

One is set as a rigidbody collider, the other is set as a static trigger collider. This means you would need to handle triggers not colliders. So you would want either OnTriggerEnter or OnTriggerEnter2D. Look at this link for a chart on which setups will cause collisions vs triggers:

You are using OnCollisionEnter(Collision col), use OnCollisionEnter2D(Collision2D col) instead.