Physics2D.IgnoreLayerCollision()

Does Physics2D.IgnoreLayerCollision() work? I can’t get it too work and I’ve seen many posts saying that it should work or that it doesn’t.

I have the following code on my character who is standing on an edge collider. I press drop, and get both messages in the console saying that it all executed. I tried setting all layers to become ignored just to get it working. I will update that later once it works.

any ideas?

using UnityEngine;
using System.Collections;

public class IgnoreLayer : MonoBehaviour {

	
	void Start () {
	
	}
	

	void Update () {

		bool drop = Input.GetButtonDown ("Drop");
		if (drop) 
		{
						
			Debug.Log ("drop called");
			Drop ();

			}
	
	}

	void Drop()
	{

		Physics2D.IgnoreLayerCollision(1, 31,true);
		Debug.Log ("drop arrived");

	}


}

reenable the collider on your object

public GameObject player;

void Drop()
    {
 
        Physics2D.IgnoreLayerCollision(1, 31,true);
        player.collider2D.enabled = false;
        player.collider2D.enabled = true;
        Debug.Log ("drop arrived");
 
    }