- Home /
Question by
MohammadAlizadeh · Jun 19, 2015 at 06:31 PM ·
soundcarpitch
(Flat tutorial) Problem with pitch in car script [SOLVED]
Hey there i'm using flat tutorial script and i did everything that is necessary but in Engine sound part keeps saying: ((IndexOutOfRangeException: Array index is out of range)) in line 17 i think....Thanks!
//Engine Sound
function EngineSound(){
for (var i = 0; i < gearRatio.length; i++){
if(gearRatio[i]> currentSpeed){
break;
}
}
var gearMinValue : float = 0.00;
var gearMaxValue : float = 0.00;
if (i == 0){
gearMinValue = 0;
}
else {
gearMinValue = gearRatio[i-1];
}
gearMaxValue = gearRatio[i]; <<<<AND SHOWS ME THIS LINE, WHATS A PROBLEM??????
var enginePitch : float = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue))+1;
audio.pitch = enginePitch;
}
Comment
Well my problem solved that was because of not setting up gears speed for pitching