Terrain texture specific step sounds?

Hello all, I’m working on a survival game and I would like to know how to make footstep sounds that are based off of the terrain texture. For instance grass having grass noise and sand having sand noise. You get what I’m saying I presume. But how do I do this? I’ve searched everywhere and do not want to pay. (Javascript preffered)

Well, here is an answer on how to get the terrain texture at a point on the terrain:

Once you have that, I guess you could do something like

public var grassSound : AudioClip;
public var sandSound : AudioClip;
public var audioPlayer : AudioSource;
var previousTextureType;
var currentTextureType;

function SetSound(){
 if(currentTextureType != previousTextureType){
   if(currentTextureType == "Grass") audioPlayer.clip = grassSound;
   else if(currentTextureType == "Sand") audioPlayer.clip = sandSound;
   previousTextureType = currentTextureType;

function GetCurrentTexture(){
 //here do something to get current texture type. see link above.

function Update(){


my SetSound function here just changes the audio clip of the audiosource when the texturetype changes. which I have sort of assumed is a string here, but see the link above for how to get it. I haven’t put in any code to start/stop playing as that’s a separate issue.

Also I’m more of a c# person so maybe there are javascript errors.