- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
rooted · Nov 07, 2013 at 06:43 AM ·
audiosourceaudioclipaudiolisteneraudio.playoneshot
Why do AudioClips still play with no Audiolistener?
I've noticed that audioclips chosen from script(see below) to an object's audiosource have some weird behaviors. You can still hear the audio clips if AudioListener is disabled or deleted. In this case, they are footsteps of the player and enemies. Why would these audio clips bypass the AudioListener totally? I can mute and adjust the volume curve but that is it. But ideally there should be no sound at all if AudioListener is disabled. Filters such as low pass filters have no effect on the audioclip managed by the game object's audiosource as well.
I've noticed this in the Angry Bots demo.
#pragma strict
@script RequireComponent(AudioSource)
//@script RequireComponent(AudioLowPassFilter)
enum FootType {
Player,
Mech,
Spider
}
var audioSource: AudioSource;
//var audioLowPassFilter : AudioLowPassFilter;
var footType : FootType;
private var physicMaterial : PhysicMaterial;
function OnCollisionEnter (collisionInfo : Collision) {
physicMaterial = collisionInfo.collider.sharedMaterial;
}
function OnFootstep () {
audioSource.enabled = true;
if (!audioSource.enabled)// && audioLowPassFilter.enabled)
{
return;
}
var sound : AudioClip;
switch (footType) {
case FootType.Player:
sound = MaterialImpactManager.GetPlayerFootstepSound (physicMaterial);
break;
case FootType.Mech:
sound = MaterialImpactManager.GetMechFootstepSound (physicMaterial);
break;
case FootType.Spider:
sound = MaterialImpactManager.GetSpiderFootstepSound (physicMaterial);
break;
}
audioSource.pitch = Random.Range (0.98, 1.02);
audioSource.PlayOneShot (sound, Random.Range (0.8, 1.2));
}
Any ideas?
Comment