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");
}
ibbybn
November 9, 2019, 11:09pm
2
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.
Hi, So i read the documentation but I didn’t understood that much, and couldn’t fix my problem. Actually I have this public LayerMask defaultLayer; public LayerMask reversedLayer; I would like to change the layer in a fuction void...
other.gameObject.layer = LayerMask.NameToLayer("invisibleEnemyunit");
Thanks bro, unfortunately that gave me the same error
1 Like