Hello,
I made this script i’ll explain what it does when you press down wsad it plays the audio file of grass walking when i release it stopped well it works only for the w key on release the asd keeping looping the audio file is there something i’m doing wrong?
using UnityEngine;
using System.Collections;
public class PlayerAudio : MonoBehaviour {
public AudioSource Audio;
public AudioClip WalkingOnGrass;
// Update is called once per frame
void Update () {
if(Input.GetKeyDown("w") || Input.GetKeyDown("s") || Input.GetKeyDown("a") || Input.GetKeyDown("d"))
audio.Play();
else if
(Input.GetKeyUp("w") || Input.GetKeyDown("s") || Input.GetKeyDown("a") || Input.GetKeyDown("d"))
audio.Stop();
}
}