title: Unity walking sounds (if and buttons error)
body: <p>Basically, I need a script to play a walking-sound while my player is walking and a running-sound while he's running. Due to how my player is setup it needs to be done with the Input and Keys...</p>
  
  <p>I have this basic script made but it doesn't work too well. The transition from running -> walking -> stop and running -> stop and so on doesn't work consistently or even well. The other problem is pressing shift while standing still also plays the sound. I already tried doing the SHIFT &amp;&amp; W || W &amp;&amp; SHIFT and it just doesn't work.</p>
  
  <p>Any help would be much appreciated!!</p>
  
  <p>My Foley.cs script:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Foley : MonoBehaviour {
  
  public AudioClip Footsteps;
  
  public AudioClip RunningSound;
  
  // Update is called once per frame
  void Update () {
      if (Input.GetKeyDown(KeyCode.LeftShift) &amp;&amp; !audio.isPlaying)
      {
          audio.clip = RunningSound;
          audio.loop = true;
          audio.Play();
      } else if (Input.GetKey(KeyCode.W) &amp;&amp; !audio.isPlaying &amp;&amp; !Input.GetKey(KeyCode.LeftShift)) {
          audio.clip = Footsteps;
          audio.loop = true;
          audio.Play();           
      }
  
      if (Input.GetKeyUp(KeyCode.W) &amp;&amp; audio.isPlaying)
      {
          audio.Stop();
      }
  
      if (Input.GetKeyUp(KeyCode.LeftShift) &amp;&amp; audio.isPlaying)
      {
          if (Input.GetKey(KeyCode.W)) 
          {
              audio.clip = Footsteps;
              audio.loop = true;
              audio.Play();           
          } else {
              audio.Stop();
          }
      }
  }
  }
  </code></pre>