I have a static ContactFilter2D like so:

protected static ContactFilter2D contact_filter;
protected float self_destruct_timer;
protected Vector3 direction;
private float xward;

protected virtual void Start ()
{    phys.velocity = transform.right * speed * xward;
     self_destruct_timer = Time.time + life_time;

     if (!contact_filter.isFiltering) contact_filter.layerMask = Public_Const.Solid;
     contact_filter.useLayerMask = true;

Every isFiltering_____ variable (i.e. isFilteringLayerMask) is set to false by default, therefore there should be no way that isFiltering should return a true value. The whole point of checking to see if isFiltering is true is to check to see if the contact filter has already been initialized, so why won't it work?

  • \$\begingroup\$ I'm confused as to what you expect to happen, and what is actually happening in your example. Could you edit to clarify? \$\endgroup\$
    – Alex F
    Feb 23, 2019 at 1:37
  • \$\begingroup\$ Isn't it? Is contact_filter.layerMask = Public_Const.Solid; being run or not? \$\endgroup\$
    – Alex F
    Feb 24, 2019 at 6:50
  • \$\begingroup\$ Sorry for the late reply but no it is not. Again everything else in the default is set to either 0 or false, safe for the static member, and the layermask which is a structure consisting of two variables both of which are 0. \$\endgroup\$
    – Caston
    Mar 1, 2019 at 15:22

1 Answer 1


Okay so apparently the code for IsFiltering looks like:

    public bool isFiltering => !useTriggers || useLayerMask || useDepth || useNormalAngle;

So I guess that not using triggers filters out triggers, therefore returning true. I guess I'll check to see if contact_filter is initialized by checking useLayerMask, and then setting that to true in the conditional.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .