I’m creating a vehicle editor where you have a list of parts you can place into the world.
After instantiating a part, I want it to immediately destroy itself if it has been placed onto another solid object, so I set up this function:
public void Place()
{
Collider2D coll = GetComponent<Collider2D>();
ContactFilter2D filter = new ContactFilter2D().NoFilter();
List<Collider2D> results = new List<Collider2D>();
if (Physics2D.OverlapCollider(coll,filter,results)>0) Destroy(this);
}
This, however, doesn’t work, and I suspect the probles is with the ContactFilter2D. What am I doing wrong?