Game Development Reference
In-Depth Information
void ChangeSpeed(float Speed)
{
if(Speed > 3)
Speed = 3;
if(Speed < -3)
Speed = -3;
audio.pitch = Speed;
}
This function takes a float variable, which will be used to determine the speed of
the song. The maximum speed value is 3 , the minimum value is -3 , and the default
value is 1 . When the speed is changed with this function, we check to make sure that
the new value is within these boundaries. Once we check the value and it is correct,
we set the pitch of AudioSource to the new speed.
Search WWH ::




Custom Search