Hello everyone! I am now working on my game, and I want to make a radio system like GTA or Saints Row in my game. For 1st try I wanted to use gameobject with attached script and 2 audiosources with audioclips. I wrote script, which on button press activates 1st source (deactivates 2nd); activates 2nd(deactivates 1st) but it’s wont work.
So, there is a script -
var audio1 : AudioSource;
var audio2 : AudioSource;
function Update () {
if (Input.GetKeyDown ("1"))
audio.Play(audio1);
audio.Stop(audio2);
if (Input.GetKeyDown ("2"))
audio.Play(audio1);
audio.Stop(audio2);
}
Then, I tryed another code:
var audio1 : AudioSource;
var audio2 : AudioSource;
function Update () {
if (Input.GetKeyDown ("1"))
audio1.active = true;
audio2.active = false;
if (Input.GetKeyDown ("2"))
audio1.active = false;
audio2.active = true;
}
But it’s dont work too.
I googled this topic, but people just made a radio stream from internet.
I want to use local music from game assets for radio system, and change it with keyboard button.
Thanks every one, waiting for ideas.