Hey,
I’m fairly new to scripting wanted to know if anyone would mind helping me out. I have been attempting to expand the functionality of the AudioSource component in javascript to include
Randomised play from selection of samples
Chance the SFX will play in percentage
Randomised pitch between ranges
Randomised volume between ranges
Voice limiter
So far I’ve been able to able to implement everything but the voice limiting and the ‘weighting’ or probability a SFX will play.
Here is my script so far, would anyone be able to point me in the right direction?
#pragma strict
var SFX : AudioClip[ ];
var MinPitchVariation = 0.9f;
var MaxPitchVariation = 1.1f;
var MinVolumeVariation = 0.9f;
var MaxVolumeVariation = 1.1f;
function Update () {
if(Input.GetButtonUp(“Jump”))
{
//Random play from Array
GetComponent.().clip = SFX[Random.Range(0, SFX.Length)];
//Random Volume
GetComponent.().volume = Random.Range (MinVolumeVariation, MaxVolumeVariation);
// Random Pitch
GetComponent.().pitch = Random.Range(MinPitchVariation, MaxPitchVariation);
//Chance SFX will Play (Default to 100% chance)
//Voice Limiting
//Play SFX
GetComponent.().Play();
}
}