When I walk into the trigger the sound plays but it is ver quiet, i tried to change this in the audio source but it turns out it has it own and only appears when you enter it. heres the script:
private var soundPlayed : boolean = false;
var Audio : AudioClip;
function OnTriggerEnter(col : Collider){ //Play Sound if player enters trigger
if (!soundPlayed && Audio) { // but only if it has not played before
AudioSource.PlayClipAtPoint(Audio, transform.position);
soundPlayed = true; // sound will not play anymore
}
}
PlayClipAtPoint creates a temporary AudioSource just to play the sound, and destroys it as soon as the sound finished. To solve problems like yours, the wise Unity guys provided a third parameter in PlayClipAtPoint, which sets the volume (0…1):
...
AudioSource.PlayClipAtPoint(Audio, transform.position, 0.4); // set volume to 0.4
...
You can also have the volume in a variable and pass it to the function:
var volume: float = 0.45; // alter the volume here, if you need
...
AudioSource.PlayClipAtPoint(Audio, transform.position, volume); // set volume
...
thanks for the solution.. so simple worked for me :)
thanks for the solution.. so simple worked for me :)
– osherm