protected void PlayMoveSound(float speed) { if (slidePitchFactor > 0f) { float targetPitch = Mathf.Min(1f, speed * slidePitchFactor); moveSound.audioSource.pitch = Mathf.Lerp(moveSound.audioSource.pitch, targetPitch, Time.deltaTime * 3f); } if (speed > slideSoundThreshold) { if (!moveSound.IsPlaying()) { moveSound.Play(moveSoundClip, true); } } else if (moveSound.IsPlaying() && !moveSound.IsFading()) { moveSound.FadeOut(0.2f); } }
protected void PlayMoveSound(float speed, float trackValue) { if (speed > slideSoundThreshold) { moveSound.relativeVolume = (speed - slideSoundThreshold); // * 5f; moveSound.SetMaxVolume(); if (slidePitchFactor > 0f) { moveSound.GetComponent <AudioSource>().pitch = Mathf.Lerp(GetComponent <AudioSource>().pitch, Mathf.Min(1f, speed), Time.deltaTime * 5f); } } if (speed > slideSoundThreshold && !moveSound.IsPlaying()) // && trackValue > 0.02f && trackValue < 0.98f) { moveSound.relativeVolume = (speed - slideSoundThreshold); // * 5f; moveSound.Play(moveSoundClip, true); } else if (speed <= slideSoundThreshold && moveSound.IsPlaying() && !moveSound.IsFading()) { moveSound.FadeOut(0.2f); } }