private void FixedUpdate() { var doFixedStep = AutoSteppingMode == AutoSteppingModes.FixedUpdate && ( // First time step. !m_stepForwardTimer.isRunning() || // Do step as long as this FixedUpdate hasn't been called // several times exceeding wall clock time > factor * time step size. 0.001f * (float)m_stepForwardTimer.getTime() / TimeStep <= 1.0f / FixedUpdateRealTimeFactor ); if (doFixedStep) { if (!m_stepForwardTimer.isRunning()) { m_stepForwardTimer.start(); } DoStepInternal(); } }
/// <summary> /// Animate the engagement of the clutch between 0..1 over some time /// </summary> public void update() { m_brakes.update(); if (m_clutchTimer != null) { m_clutchEngaged = true; // Interpolate the clutch value from 0 to 1 var now = m_clutchTimer.getTime(); float t = (float)(now / 1000.0f / m_clutchDuration); var value = UnityEngine.Mathf.Lerp(0, 1, t); m_clutch.setEfficiency(value); Debug.Log(string.Format("Clutch {0}", value)); if (t >= 1.0f) { m_clutchTimer = null; } } }