Changing Layer Mask Error (Help please)

Hi, I Just want to change my Layer mask, but I am doing it wrong. Please Help

Error:

public LayerMask invisibleEnemyunit;
public LayerMask visible;


if (withInVisibleRange == false)
            {
                other.gameObject.layer = invisibleEnemyunit;
                Debug.Log("B");
               

            }

A layer is just an int. You’re trying to assign a LayerMask ( a set multiple layers in a bitmask if I remember correctly ) to an int field.
Just type other.gameObject.layer = 0; Or whatever number your layer has in the list.

1 Like

i’m not sure but this can help you perhaps.

 other.gameObject.layer = LayerMask.NameToLayer("invisibleEnemyunit");

Thanks bro, this worked

Thanks bro, unfortunately that gave me the same error

1 Like