using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class soundManager : MonoBehaviour
{
public AudioClip running;
public AudioClip walking;
private AudioSource Audio1;
private AudioSource Audio2;
private void Update()
{
Audio1 = GetComponent<AudioSource>();
Audio1.clip = running;
Audio1.loop = true;
if (Input.GetKeyDown(KeyCode.W) && Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.W) && Input.GetKeyDown(KeyCode.LeftShift))
{
if (!Audio1.isPlaying)
{
Audio1.Play();
}
}
if (Input.GetKeyDown(KeyCode.A) && Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.A) && Input.GetKeyDown(KeyCode.LeftShift))
{
if (!Audio1.isPlaying)
{
Audio1.Play();
}
}
if (Input.GetKeyDown(KeyCode.S) && Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.S) && Input.GetKeyDown(KeyCode.LeftShift))
{
if (!Audio1.isPlaying)
{
Audio1.Play();
}
}
if (Input.GetKeyDown(KeyCode.D) && Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.D) && Input.GetKeyDown(KeyCode.LeftShift))
{
if (!Audio1.isPlaying)
{
Audio1.Play();
}
}
if (Input.GetKeyUp(KeyCode.LeftShift))
{
Audio1.Stop();
}
}
}
currently this is what i have, so the running sound plays when either shift then WASD or WASD then shift is pressed. then once let go will stop. but i can run then take my hands of W A S or D while holding shift and it will still play the running sound
how should i fix this?