Hello, i searched this from a long time, how to i make a gear system from this audio pitch script? (depending the car speed) Thanks!
var minPitch : float = 1.0;
var maxPitch : float = 2.0;
var maxSpeed : float = 20.0; //tweak to your vehicle
private var pitchModifier : float;
function Update(){
var currentSpeed = rigidbody.velocity.magnitude;
pitchModifier = maxPitch - minPitch;
audio.pitch = minPitch + (currentSpeed/maxSpeed)*pitchModifier;
if(audio.pitch > maxPitch)
{
audio.pitch = maxPitch;
}
}
↧