Proper walk sound / audio play script c#

Hello, I could use some help on this sound while walking C# script. When I walk the sound loops and overlaps (because it’s in the update function). How do I make sure the sound doesn’t play for an certain amount of time (say half a second?

my current code `public AudioClip walkSound;

void Update () {
	if (Input.GetButton("Vertical") || Input.GetButton("Horizontal") ){
				audio.PlayOneShot(walkSound);
		}
	
	
}

}`

thanks guys

One easy way would be to move your code to its own function and use InvokeRepeating(). The last parameter is how often the test will be repeated.

void Start() {
	InvokeRepeating ("PlaySound", 0.0f, 0.5f);	
}
	
void PlaySound () {
    if (Input.GetButton("Vertical") || Input.GetButton("Horizontal") ){
          audio.PlayOneShot(walkSound);
    }
}