Skip to content

Instantly share code, notes, and snippets.

@awilki01
Last active October 5, 2016 02:20
Show Gist options
  • Save awilki01/99c85eb8ea2724408ea7a95600ba1e10 to your computer and use it in GitHub Desktop.
Save awilki01/99c85eb8ea2724408ea7a95600ba1e10 to your computer and use it in GitHub Desktop.
void FixedUpdate () {
// non-pertinent code not depicted
if (thrust > 1.0f) {
PlayThrustSound();
} else StopPlayThrustSound();
}
private void PlayThrustSound() {
if (!ThrustSound.isPlaying) {
_thrustVolume = 1.0f;
ThrustSound.volume = _thrustVolume;
ThrustSound.Play();
}
}
private void StopPlayThrustSound() {
//float _StartTime = Time.time;
_thrustVolume -= 0.03f;
ThrustSound.volume = _thrustVolume;
if (_thrustVolume <= 0.0f) {
ThrustSound.Stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment