I’ve used LayerMasks a lot in the past but right now I’m having a really weird interaction and wanted to make sure it wasn’t something stupid I was doing before submitting it as a bug. I’ve got layers called “Player” and “Enemy” as well as an “Allegiance” setting that is either player or enemy as well. Based on your allegiance, I’m changing the layerMask of your attack to hit your opponent. Here’s my code:
public Allegiance allegiance;
public LayerMask enemyLayers;
public Start() {
enemyLayers = allegiance == Allegiance.Player ? LayerMask.NameToLayer("Enemy") : LayerMask.NameToLayer("Player");
}
When this runs and I check the script in the inspector, the one set to “Player” does not have the player layer selected but instead has the Default, TransparentFX, and Ignore Raycast layers selected. The enemy has only has TransparentFX and Ignore Raycast. They both should have none of that as the default setting is “Nothing”. This happens even if I just set enemyLayers to be Enemy or Player without the conditional.
Any idea why this is happening?