void Update() { if (_fixedUpdateCount < 2) { return; } try { if (audioSource.clip == null) { return; } if (_gamePaused) { if (audioSource.isPlaying) { audioSource.Stop(); } return; } if (audioSource.loop && !audioSource.isPlaying) { audioSource.time = UnityEngine.Random.Range(0, audioSource.clip.length); audioSource.Play(); } else if (_playSoundSingle) { audioSource.Play(); _playSoundSingle = false; } else if (oneShot) { if (_oneshotTimeOut != 0) { _oneshotTimeOut--; return; } float thrustDelta = (thrustPow - lastThrust) * 60; if (thrustDelta > oneShotSensitivity) { audioSource.Play(); _oneshotTimeOut = oneShotTimeout; } } if (thumpAmount > 0) { float thrustDelta = (thrustPow - lastThrust) * 60; if (thrustDelta > thumpSensitivity) { _thumper = thumpAmount; } float thumpProgress = _thumper / thumpAmount; //_thumper = Mathf.MoveTowards(_thumper, 0, (thumpRate * thumpProgress) * Time.deltaTime); _thumper = Mathf.MoveTowards(_thumper, 0, thumpRate * Time.deltaTime); } audioSource.pitch = pitch.Value(thrustPow) + _thumper; AudioFX.SetSourceVolume(audioSource, Mathf.Clamp(volume.Value(thrustPow), 0, 3), channel); lastThrust = thrustPow; } catch { return; } }