/// <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);
            }
        }
        /// <summary>
        /// When this feedback gets played
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active)
            {
                return;
            }

            switch (HapticMethod)
            {
            case HapticMethods.AdvancedPattern:

                string iOSString = (AHAPFileForIOS == null) ? "" : AHAPFileForIOS.text;

                long[] androidPattern   = (AndroidWaveFormFile == null) ? null : AndroidWaveFormFile.WaveForm.Pattern;
                int[]  androidAmplitude = (AndroidWaveFormFile == null) ? null : AndroidWaveFormFile.WaveForm.Amplitudes;

                long[] rumblePattern     = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.Pattern;
                int[]  lowFreqAmplitude  = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.LowFrequencyAmplitudes;
                int[]  highFreqAmplitude = (RumbleWaveFormFile == null) ? null : RumbleWaveFormFile.WaveForm.HighFrequencyAmplitudes;

                MMVibrationManager.AdvancedHapticPattern(APVibrateIOS, iOSString, APVibrateAndroid, androidPattern, androidAmplitude,
                                                         AndroidRepeat, APVibrateAndroidIfNoSupport, APRumble,
                                                         rumblePattern, lowFreqAmplitude, highFreqAmplitude, RumbleRepeat,
                                                         OldIOSFallback, this, ControllerID);
                break;

            case HapticMethods.Continuous:
                StartCoroutine(ContinuousHapticsCoroutine());
                break;

            case HapticMethods.NativePreset:
                MMVibrationManager.Haptic(HapticType, false, AllowRumble, this, ControllerID);
                break;

            case HapticMethods.Transient:
                MMVibrationManager.TransientHaptic(TransientIntensity, TransientSharpness, AllowRumble, this, ControllerID);
                break;

            case HapticMethods.AdvancedTransient:
                MMVibrationManager.TransientHaptic(ATVibrateIOS, ATIOSIntensity, ATIOSSharpness, ATVibrateAndroid,
                                                   ATAndroidIntensity, ATAndroidSharpness, ATVibrateAndroidIfNoSupport, ATRumble,
                                                   ATRumbleIntensity, ATRumbleSharpness, ATRumbleControllerID, this);
                break;

            case HapticMethods.AdvancedContinuous:

                break;

            case HapticMethods.Stop:
                if (_continuousPlaying)
                {
                    MMVibrationManager.StopContinuousHaptic(AllowRumble);
                    _continuousPlaying = false;
                }
                break;
            }
        }
示例#3
0
    private void OnDeath()
    {
        gameObject.SetActive(false);
        IsPlayerDead.Value = true;
        GameObject ragdoll = Instantiate(ragdollPrefab, transform.position, transform.rotation);

        Rigidbody[] ragdollsRbs = ragdoll.GetComponentsInChildren <Rigidbody>();
        ragdollsRbs.ForEach(r => r.velocity = PreviousVelocity.Value);
        freeLookCam.Follow = ragdollsRbs[0].transform;
        freeLookCam.LookAt = ragdollsRbs[0].transform;

        //Force stop all vibrations to prevent getting stuck
        LeanTween.value(0f, 1f, .5f)
        .setOnComplete(_ =>
        {
            MMVibrationManager.StopContinuousHaptic(true);
            MMVibrationManager.StopAllHaptics(true);
        });
    }
 public static void StopContinuousVibration()
 {
     MMVibrationManager.StopContinuousHaptic();
 }
示例#5
0
 void OnApplicationQuit()
 {
     //Stop all vibrations when quitting game/editor, to prevent getting stuck
     MMVibrationManager.StopContinuousHaptic(true);
     MMVibrationManager.StopAllHaptics(true);
 }