Raycast sometimes failing to detect colliders physic material

So I’ve been working on a world that has a footstep system. It uses a physics raycast slightly above the players position to detect what physics material the collider below is using, and sets the footstep sound accordingly. In the editor, it detects the physic material without any issues. In game, it only seems to detect sometimes, and other times failing to detect anything at all. I’ve already made sure the position isn’t incorrect, and there’s a LayerMask to prevent it from hitting the UI or Player layers, so I’m at a loss as to why it isn’t working. Is there something I’m missing?