Hi, I’m just trying to make it that when an NPC called pilot moves to a certain location, an audio clip plays once. As it is, when the NPC is in position the audioclip plays in a crazy loop like a machine gun.
Any advice would be great.
public GameObject pilot;
public AudioClip TooLoud;
public GameObject player;
//public float DistSound = 3;
public GameObject SoundSource;
// Use this for initialization
void Start()
{
SoundSource.GetComponent<AudioClip>();
SoundSource.GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
if (pilot.transform.position.y < 0.8)
/*(Vector3.Distance(player.transform.position, pilot.transform.position) < DistSound)*/
{
SoundSource.GetComponent<AudioSource>().PlayOneShot(TooLoud);
}
}
}