Hi, I have 2 sounds on a script a fire sound and a thruster sound. How to I stop 1 specifically on 1 script because right now if I move forward, my thruster sound goes and loops and is fine, but when I shoot while moving forward then my fire sound goes and loops and the thruster stops. I just want to have the thruster loop while I hit W and the fire not loop but play once when I shoot, they are both in the same script and same game object. Here is my code.
using UnityEngine;
using System.Collections;
public class Shooting_CJ : MonoBehaviour {
public AudioClip Laser;
public AudioClip Thruster;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("space"))
{
audio.clip = Laser;
audio.Play();
}
if (Input.GetKeyDown(KeyCode.W))
{
audio.loop = true;
audio.clip = Thruster;
audio.Play();
}
if (Input.GetKeyUp(KeyCode.W))
{
audio.Pause();
audio.loop = false;
}
else
{
}
}
}