hello im new in unity , i want to set 2 layer mask for boxcast but i dont know how , like i want to say if the player collider was touching ground and wall layer collider the player is grounded || and && didnt work in this case ,can anyone help? Code (CSharp): private bool isGrounded() { RaycastHit2D raycast = Physics2D.BoxCast(collider.bounds.center, collider.bounds.size, 0, Vector2.down, 0.1f, groundLayer); return raycast.collider != null; }
Use the bitwise logic operators (single | and &) in this case, not the Boolean operators (double || and &&). The bitwise operators operate on each single digit in the binary number. They are often used with values that are treated as masks or flags. See https://docs.unity3d.com/2020.3/Documentation/Manual/layermask-add.html for an example of how to add an additional layer to a layer mask.