audio problem!!

hey guys, I got a house scene. how do I set 2 audio sources into a same scene. As in when I am outside of the house, one sound will be played. When I am inside the house another sound will be played ? Do I need a script or what ? Can that be done ?

new yorker? ah nevermind. add an empty and then add an audio source. rinse and repeat (or add an audio source to the house and just do it once). you’ll need to script/trigger the change unless they can both play at the same time.

nope. Singaporean. haha, I am not good with scripting. What the script be like ? Thanks anyway (:

You could try something like this:

Create two empty game objects, and attach an AudioSource component to each. Name one object “HouseSound”, and the other “OutsideSound”.

Write a script that basically states:

var aud : AudioSource;
if(inHouse)
{
aud.clip = GameObject.Find(“HouseSound”).GetComponent(AudioSource).clip;
}
else
{
aud.clip = GameObject.Find(“OutsideSound”).GetComponent(AudioSource).clip;
}

aud.Play();

Of course, that code assumes that you have a bool variable inHouse, which can be toggled true / false depending on the player’s location.