Hi!
I’m trying to crossfade two audio clips on one key press but I just can’t wrap my head around it.
I have a game object with two children (both have an audio source).
The current script that I’m using works but not as intended.
using UnityEngine;
using System.Collections;
public class scr_MusicController : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown("n"))
{
transform.FindChild("aud_Normal").audio.volume = 1;
transform.FindChild("aud_8bit").audio.volume = 0;
}
if (Input.GetKeyDown("m"))
{
transform.FindChild("aud_Normal").audio.volume = 0;
transform.FindChild("aud_8bit").audio.volume = 1;
}
}
}
I want to assign this cycle to single key and the volume increase to take one second to reach it’s assigned value (as well on the volume decrease of course).
I know this is a lot to ask but please, I’m stuck in here
Thanks for your help!