Unity How to detect 2D Collision

Make sure your game object has a 2D collider on it. In the script have a method 'OnCollisionEnter2D'. You can see what the other object was via its 'tag'. Make sure to set it for your game objects.

Collision.cs
void OnCollisionEnter2D(Collision2D coll) {	
	if (coll.gameObject.tag == "bullet") {
		// do stuff...
	}
}
Navigation
Print/export
Toolbox