[Solved] Volume of a AudioClip

Hey

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.

Thanks in advance
Thomas

Hey

Have you tried this

GetComponent<AudioSource>().volume = yourVolume;

Don’t know if it’s helpfull.

Simon

I found the solution in one of the next lectures.

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.

Glad you find the solution, and sorry that I couldn’t helped ! ^^