Unity 2D getting projectiles to regitser collisions

I have a project using 2D in which a character shoots projectiles, they are supposed to (among other things) collide with walls, and destroy on contact. My walls are sitting on a layer called “Walls Collide” and this is the code I have for the projectiles:

using UnityEngine;
using System.Collections;

public class Projectile : MonoBehaviour 
{
	public GameObject projHit;
	
	
	void Start () 
	{
	}
	
	
	void OnTrigger2D (Collider2D col) 
	{
		if(col.gameObject.layer == 1 << LayerMask.NameToLayer ("Walls Collide"))
		{
			//if it hits a wall, get rid of it
			Destroy (gameObject);
		}

Unfortunately, the projectiles pass straight through the walls without any response, they have a circle collider as they are in fact round, any ideas how to fix this?

I’m having some trouble with Unity’s collision system in 2D as well, but here are some things you can try:

  1. your function name is wrong. Try OnTriggerEnter2D(Collider2D col)

  2. step 1 only works if your wall is set up as a trigger. If not, try OnCollisionEnter2D(Collision2D other)

  3. If both of those didn’t work try this:

    Projectile is a rigidbody2D. 2D Collider , isTrigger set to False

    Wall is a rigidbody2D. Kinematic is set to off. GravityScale set to 0. 2D Collider isTrigger is set to True

This works for me.