public void StartEngine() { fader = new CrankcaseAudio.Fade(FADE_DURATION_MS, 0.0f, 1.0f, CrankcaseAudio.eCurveType.SQRD); if (physicsSimulator != null) { physicsSimulator.StartEngine(); } if (engineSimulator != null) { engineSimulator.Volume = 0.0f; engineSimulator.StartEngine(); } isEngineRunning = true; }
// Update is called once per frame protected void Update() { if (engineSimulator != null && physicsSimulator != null) { float deltaTime = Time.deltaTime; if (fader != null) { this.fadeVolume = fader.Update(deltaTime); if (fader.isComplete) { fader = null; } engineSimulator.Volume = this.masterVolume * this.fadeVolume; } REVPhysicsSimulator.PhysicsOutputParameters outputParams = physicsSimulator.OutputParams; engineSimulator.Throttle = outputParams.Throttle; engineSimulator.Velocity = outputParams.Velocity; engineSimulator.Rpm = outputParams.Rpm; engineSimulator.Gear = outputParams.Gear; } }
public void FadeEngine(Action completionAction = null) { fader = new CrankcaseAudio.Fade(FADE_DURATION_MS, 1.0f, 0.0f, CrankcaseAudio.eCurveType.TO_THE_HALF); fader.completionAction = completionAction; }