Heyyooo
I am trying to make a game, where there is a plane, and the engine is Emitting a sound from a sound source, when i press W + Shift the plane accelerates. I want to use another sound for the engine when i press W + Shift and when i let go, it goes back to the regular sound. but so far i couldn’t do it. Help?
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class Example : MonoBehaviour
{
public AudioClip sound1;
public AudioClip sound2;
void Update()
{
if(Input.GetKey (KeyCode.W) && Input.GetKey (KeyCode.LeftShift))
{
audio.clip = sound1;
}
else
audio.clip = sound2;
if(!audio.isPlaying)
audio.Play ();
}
}