Title says it al.
Initially I was using:
hit.transform.gameObject.layer == LayerMask.NameToLayer("Floor")
But eventually I figured out I needed different layers for different floors, I figured I should use a LayerMask, please correct me if I'm wrong but can't get it to work.
At the top of the document I have:
public LayerMask floorLayers;
In the void Update I have:
int floorMask = ~floorLayers.value;
And in the if statement I have:
if (playerHasWetFeet == true && wetSteps < maxWetSteps && controller.isGrounded && hit.transform.gameObject.layer == floorMask)
This however isn't working.
Can anyone point me out what I'm doing wrong?
Edit:
This is within my update function:
int floorMask = ~floorLayers.value;
currentFrameFootstepLeft = anim.GetFloat("FootstepLeft");
if (currentFrameFootstepLeft > 0 && lastFrameFootstepLeft < 0)
{
if (Physics.Raycast(transform.position, dirDown, out hit, 10f, floorMask))
{
if (playerHasWetFeet == true && wetSteps < maxWetSteps && controller.isGrounded && (1 << hit.transform.gameObject.layer & floorMask) != 0)
{
LeftWetStepSpawner();
Debug.Log("Hit");
}