I’m trying to change the volume of an audio file.
This is the code:
public AudioClip crack;
void OnCollisionEnter2D (Collision2D collision){
AudioSource.PlayClipAtPoint (crack, transform.position);
if (isBreakable){
HandleHits();
}
}
But the crack-sound is to loud. How can I set the volume in code?
A simple “crack.volume” seems not to exist, and I can’t find any other method or parameter.
You have to modify the following code: AudioSource.PlayClipAtPoint (crack, transform.position);
to this code: AudioSource.PlayClipAtPoint (crack, transform.position, 0.2f);
With 0.2f the value of the volume you want.