function OnTriggerEnter (bomb : Collider) {
audio.Play(); //play boom boom explosion
health = health - 5;
Destroy(gameObject);
}
Main Camera has Audio Listener
Object with script attached has Audio Source with clip attached and the following parameters.
Audio Source (checked)
Audio Click Explosion_3
Play on Awake (not checked)
Volume 1
Pitch 1
Min Volume 0
Max Volume 1
Rolloff Factor 0.1
Loop (not checked)
Any ideas why this does not work? Also, I used the Play On Awake to test the clip and that seemed to work fine.
maby because you’r deleting the gameobject the audio is on =.=
Then how can I play the audio clip (2 second length), then destroy the object?
AudioSource.PlayClipAtPoint(clippy, position, volume)
You’ll have to create a variable to hold the clip, of course…
var clippy : AudioClip; or something.
One option is to reference the audio source on another object such as the camera. You can easily do this by declaring a target variable with type of AudioSource, then in the inspector you can drag the source of the audio onto the drop point. I would just recommend creating some code that pseudo does this:
//Pseudo
if(!Target.IsPlaying){
Target.Play();
}
Just so there is no double plays.