AudioRamp
Never
using UnityEngine; namespace Darkersmile { public class EngineAudio : MonoBehaviour { [Header("Control")] [Range(0, 1)] [Tooltip("The actual percentage of the total pitch")] public float DesiredPitchPercentage = 0.5f; [Header("Settings")] [Range(0.01f, 1)] [Tooltip("How fast the pitch catches up to the desired volume")] public float PitchAcceleration = 0.15f; [Tooltip("The minimum and maximum possible pitch")] public Vector2 PitchRange = new Vector2(0, 2); [Tooltip("Pitch Eval Curve")] public AnimationCurve Curve = AnimationCurve.EaseInOut(0, 0, 1, 1); [Header("Read Only")] [Tooltip("The actual current pitch")] [Range(0, 1)] public float currentPitchPercentage; void Awake() { _source = GetComponent<AudioSource>(); currentPitchPercentage = Percentage(_source.pitch, PitchRange.x, PitchRange.y); } void Update() { UpdateEngineAudioPitch(); } void UpdateEngineAudioPitch() { if (currentPitchPercentage > DesiredPitchPercentage) currentPitchPercentage -= Time.deltaTime * PitchAcceleration; if (currentPitchPercentage < DesiredPitchPercentage) currentPitchPercentage += Time.deltaTime * PitchAcceleration; _source.pitch = Mathf.Lerp(PitchRange.x, PitchRange.y, Curve.Evaluate(currentPitchPercentage)); } public static float Percentage(float current, float start, float end) { return (current - start) / (end - start); } private AudioSource _source; } }
Raw Text
-
MenoPhix FAKE Hype Busted [Consumer Reports] Is MenoPhix afe?
5 min ago
-
What Can The Music Industry Teach You About Bloom Cbd Gummies
13 min ago
-
Less Reading More Sucking & Fucking feat. The Nerd Harley King - Exxxtra Small
21 min ago
-
Adult Telegram Channels
36 min ago
-
5 FitsPresso Tips for Swift Weight Loss
39 min ago
-
What to anticipate with the consumption of Bloom CBD Gummies?
40 min ago
-
I’m obsessed with anal, that's what makes me happy
51 min ago
-
yuty dgh fdg hfg
1 hour ago
-
c---p folder mega💯
1 hour ago
-
"Why Does It Smell Like Sex?" Slutty Wife Caught With Another Man - Lucky Anne - TouchMyWi
1 hour ago