/// <summary> /// A coroutine used to update continuous haptics as they're playing /// </summary> /// <returns></returns> protected virtual IEnumerator ContinuousHapticsCoroutine() { _continuousStartedAt = (Timescale == Timescales.ScaledTime) ? Time.time : Time.unscaledTime; _continuousPlaying = true; float elapsedTime = ComputeElapsedTime(); MMVibrationManager.ContinuousHaptic(InitialContinuousIntensity, InitialContinuousSharpness, ContinuousDuration, HapticTypes.Success, this); while (_continuousPlaying && (elapsedTime < ContinuousDuration)) { elapsedTime = ComputeElapsedTime(); float remappedTime = Remap(elapsedTime, 0f, ContinuousDuration, 0f, 1f); float intensity = ContinuousIntensityCurve.Evaluate(remappedTime); float sharpness = ContinuousSharpnessCurve.Evaluate(remappedTime); MMVibrationManager.UpdateContinuousHaptic(intensity, sharpness, true); if (AllowRumble) { #if MOREMOUNTAINS_NICEVIBRATIONS_RUMBLE MMNVRumble.RumbleContinuous(intensity, sharpness, ControllerID); #endif } yield return(null); } if (_continuousPlaying) { _continuousPlaying = false; MMVibrationManager.StopContinuousHaptic(AllowRumble); } }
private void ClickAndGo() { if (Input.GetMouseButtonUp(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; MMVibrationManager.ContinuousHaptic(.5f, .5f, 100); if (Physics.Raycast(ray, out hit)) { Debug.Log(hit.point); cursor.transform.position = hit.point; moveable.GetComponent <NavMeshAgent>().SetDestination(hit.point); } } }
private void TouchAndGo() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Ended) { Ray ray = Camera.main.ScreenPointToRay(touch.position); RaycastHit hit; MMVibrationManager.ContinuousHaptic(.5f, .5f, 100); if (Physics.Raycast(ray, out hit)) { Debug.Log(hit.point); cursor.transform.position = hit.point; moveable.GetComponent <NavMeshAgent>().SetDestination(hit.point); } } } }
/// <summary> /// 开启一个持续的震动 /// </summary> /// <param name="intensity">震动的强度</param> /// <param name="sharpness">震动的锐度</param> /// <param name="duration">震动的持续时间</param> /// <param name="fallbackOldiOS"></param> /// <param name="mono"></param> /// <param name="alsoRumble"></param> /// <param name="controllerID"></param> /// <param name="threaded"></param> /// <param name="fullIntensity"></param> public static void StartContinuousVibration(float intensity, float sharpness, float duration, HapticTypes fallbackOldiOS = HapticTypes.None, MonoBehaviour mono = null) { MMVibrationManager.ContinuousHaptic(intensity, sharpness, duration, fallbackOldiOS, mono); }