I am trying to make a MMO game with Unity 4.2 and I can built it successfully but when I play into Unity I got several warnings like for example:
A game object can only be in one layer. The Layer need to be in the range[ 0....31] UnityEngine.Gameobject: set_layer(int32)
Could anybody help me to fix these ones?
It seems that GameObjects and LayerMasks work differently and the error thrown is wrong. Use bitshifting tricks (1 << 13) for raycasts/layermasks and the shiftcount (13) for the gameobjects (.layer), I know it doesn't make sense, but it's different for both. I just wasted half an hour with this.
Layers in Unity are defined as an integer mask. What this in essence means is that they are defined inside the engine by an integer value where a single bit is set.
So if you set your layer to have a value of 0, the actual mask integer value is 1 << 0. Or if you set it to be 2, the actual integer mask value stored is 1 << 2. It should not be too hard to imagine why you can then only have 32 distinct layers. There are 32 bits in an integer after all.
So check what you set your layers to and see if they are within range.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With