using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Game.Controllers {
[System.Serializable]
public struct IgnoreLayersStruct {
public LayerMask Layer1;
public LayerMask Layer2;
}
public class GameController : MonoBehaviour {
public IgnoreLayersStruct[] ignoreLayers;
// Use this for initialization
private void Awake () {
DoIgnoreLayers();
}
private void DoIgnoreLayers() {
foreach (IgnoreLayersStruct L in ignoreLayers) {
Physics.IgnoreLayerCollision(L.Layer1.value, L.Layer2.value);
}
}
}
}
I am receiving the error:
By debugging it, Layer1 have value of 256 and Layer2 have a value of 512.
May i have some help on how to solve this problem?
Devs: This is a bug! shouln’d work like this! LayerMask should give us the right value of the mask since it’s expecting a value between 0 and 31.
hmm… So, i just have to bitwise it to get the value. Would be nice to LayerMask have a method that return this value for this purpose. I still don’t see the use of the brute value that LayerMassk.Value returns if i have to transform it.
I had forget that in projects Physics i can select which layer collides with what.
And besides, string layer name is really a pain when we already have LayerMask and knowing that we cannot even use it’s value to work with Physics without having to make calculations. Really disappointing.