how to check what material player stands on

i try to do footstep system by raycasting here is script that i made

public float distance;

void Update(){
Raycast hit;
Ray footstepRay = new Ray (transform.position, Vector3.down);
  If(Physics.Raycast(footstepRay, out hit, distance)){
     If(hit.collider.tag == "terrain"){

     }
  }
} 

here is the question :
how to check the material of terrain layers so that i can check which material player stands on?

Assuming that the collider has a Renderer component since your wanting to get the material you could do something like this…

if(hit.collider.tag == "terrain")
         {
        GameObject myObj = hit.collider.gameObject;
        Renderer rend = myObj.GetComponent<Renderer>();
        Material standingOnMaterial = rend.material;
        }

We use UnityEngine.Renderer for something like this:

Renderer rend = hit.transform.gameObject.GetComponent<Renderer>();
if (rend.material == materialYouWantToCheck)
    // do something

Check out my video tutorial on how to get footsteps working, if you’re still looking for a solution. My C# script is included in the video description, as well.