Exemplo n.º 1
0
        private void PlayReceiveDamageHaptics(float dmg, Vector3 direction)
        {
            if (!VRConfig.configUseBhaptics.Value)
            {
                return;
            }

            var rotationOption = GetRotationOptionFromDirection(direction);

            float intensity   = dmg * 0.3f + 0.3f;
            float duration    = 1f;
            var   scaleOption = new ScaleOption(intensity, duration);

            m_hapticPlayer.SubmitRegisteredVestRotation(VEST_DAMAGE_KEY, "", rotationOption, scaleOption);

            m_lastDamageRotationOption = rotationOption;
        }
        void ProvideHapticFeedbackThread(float locationAngle, float locationHeight, FeedbackType effect, float intensityMultiplier, bool waitToPlay)
        {
            if (intensityMultiplier < 0.001)
            {
                return;
            }

            if (!systemInitialized || hapticPlayer == null)
            {
                CreateSystem();
            }

            if (hapticPlayer != null)
            {
                if (feedbackMap.ContainsKey(effect))
                {
                    if (feedbackMap[effect].feedbackFileCount > 0)
                    {
                        if (waitToPlay)
                        {
                            if (IsPlayingKeyAll(feedbackMap[effect].prefix, feedbackMap[effect].feedbackFileCount))
                            {
                                return;
                            }
                        }

                        string key = feedbackMap[effect].prefix + (RandomNumber.Between(1, feedbackMap[effect].feedbackFileCount)).ToString();

                        if (locationHeight < -0.5f)
                        {
                            locationHeight = -0.5f;
                        }
                        else if (locationHeight > 0.5f)
                        {
                            locationHeight = 0.5f;
                        }

                        Bhaptics.Tact.RotationOption RotOption = new RotationOption(locationAngle, locationHeight);

                        Bhaptics.Tact.ScaleOption scaleOption = new ScaleOption(intensityMultiplier, 1.0f);

                        //hapticPlayer.SubmitRegistered(key, scaleOption);
                        hapticPlayer.SubmitRegisteredVestRotation(key, RotOption, scaleOption);
                    }
                }
            }
        }