- Home /
Question by
unity_YYoxtjdH92iNIg · Jan 31, 2020 at 09:46 AM ·
triggercoroutineaudiosourceontriggerenter
decreasing volume when other sound plays
Hi..i have background music and a human voice sound.. i want to decrease background volume when human voice playing..after human voice stopped,change back background music to default volume.. how can i do that ?
i tried something but to be honest i dont have any idea.. here is my trying :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class seslendirme : MonoBehaviour
{
public AudioSource kisilacakses;
public AudioSource calanses;
void OnTriggerEnter(Collider other)
{
StartCoroutine(seslendir());
}
IEnumerator seslendir()
{
while (!calanses.isPlaying)
{
kisilacakses.volume = 0.01f;
yield return null;
}
if(!calanses.isPlaying)
kisilacakses.volume = 0.5f;
}
}
Comment